Basically, the question starts asking in which city the respondent is located. Based on this response, it then calculates the country the city corresponds to. Then it asks a question using the label of the country, no the city.
But I’m not sure how to make this work WITHOUT asking first in which country are you and then in which city are you (which I don’t want to do).
I guess it could be done with pull.data() from a preloaded data that links each city with each country and reads from there, but it sounds burdensome.
Thanks for the suggestions. I attach the file here.Autolabel.xlsx (10.0 KB)
Thank you @Kal_Lam. I’m actively trying to avoid using the cascading format. I prefer not to ask first country, then district, then city. I prefer the survey to directly assume that, if the respondent says he/she is in Madrid, means the country is Spain.
I do know this will be possible with pull.data. Or with the code below. But it is always preferable not to use strings when later exporting the dataset for data analysis.
If you’re doing a single language form then you could always add an extra column in your choice list - e.g. call it Country, and put the country code against each City in the choice list.
Can then use instance() to pull the data by specifying XML path - just like you would use pulldata() from an external file but in this case the data is coming from within the same XLSForm file (an additional column in the choice tab).