Adding a hidden field for logic

Hi all,

Hoping for some guidance on this.

I have 250+ cities (in the choices sheet):

list name name label
city 1 London
city 2 Dubai
city 3 New York City
city 4 Washington DC

And this question on the survey sheet:

type name label required read_only appearance relevant choice_filter
select_one multiple city What city do you live in?

Some of the questions in my survey are only relevant for those living in cities on particular continents (e.g. Europe, North America, etc.). But, I’d prefer to not have an additional question (i.e. what continent are you on?) as we’re seeing big drop-offs between questions. Is there anyway to have some hidden field or logic that would see that ‘NYC’ is a North American city and only show the questions that are relevant for North America? Presumably we also need to add logic next to the questions that makes this work too…

Thanks!

Andrew

@AndrewXLS, you could do this through the cascading select as discussed previously:

For details, you could also have a look at our support article Adding Cascading Select Questions.

Thanks! But I’m not quite sure this works for what I’m looking to do.

I don’t want the respondent to have to select the continent, and instead for the questions to automatically be excluded if they’re not relevant to that continent. Both Options 1 and 2 at the link seem to require the respondent to do the filtering.

@AndrewXLS, didn’t understand your query. So do you mean when a respondents select an option from your choice, they should be able to see only other relevant questions related with that particular city?

Exactly that, but the questions are linked to the continent variable - and not the city…

OK, if this is your requirement, you could use the skip to skip questions or groups as needed. We have a workaround discussed previously which should help you get an idea of how you could use them:

Thanks! This is getting closer to what I’m looking for, I think!

Just to go back to my survey.

I have 250+ cities (in the choices sheet):

list name name label
city 1 London
city 2 Dubai
city 3 New York City
city 4 Washington DC

And this question on the survey sheet:

type name label required read_only appearance relevant choice_filter
select_one multiple city What city do you live in?

What I’m trying to do is add another variable to each choice - continent. So, for example, next to London will be ‘Europe’, next to NYC will be ‘North America’ etc.

Respondents will be asked at the very start of the survey which city they live in.

I would then like some questions to not appear if a city is on a particular continent. But, I would like this to happen without the respondent having to select the continent as well. I could do a big logic function, but with 250+ cities it’s going to take time!

Is there anyway to have questions not show up if, for example, a city is in ‘Europe’ - with the respondent selecting the city, and the form recognising that this is in Europe (from the choice tab - or somewhere else)?

Thanks!

OK, apart from the cities question could you also add some dummy question and your condition so that would provide a more clear picture?

No problem! I’ve attached here a demo form.
Forum test.xlsx (11.5 KB)

You could skip as outlined in the image shared below:

Here, idcard will only be active if a user selects option 3 or 4 in city.

Thanks for all of your efforts on this. Really appreciated!

That’s definitely one option, but as I have 250+ cities I’m keen to see if there’s a way to do it without having to manually add each of their numbers. Any thoughts? So, for example, how can I ensure that if someone selects one of the 100+ cities in Europe, they wouldn’t see that question?

You could do this by keeping the logic in a calculate question and then use them whenever needed as shown in the image shared below:

In the survey tab of your xlsform:

Data entry screen as seen in Enketo:

Reference xlsform:

Forum test.xlsx (11.6 KB)

Thanks! Just to confirm, though, I would need to add ‘1’, ‘2’, ‘3’, etc for each of the 100+ cities in this case?

If so, is there any logic to add that would let me say cities ‘1 through 99’ would see that question?

You could use the nested if-statement as discussed in one of our previous posts: