Use more than one filter option for choice filter in choice sheet

Hi All

1. What is the issue? Please be detailed.
I am using choice filter and would like choice filter to shows a certain option based on selection A or B.

For example, in the following choice sheet, I would like to show training option when someone selects Category finance or hr.

2. What steps can we take to reproduce this issue?
Its not an issue but a question on action/feature if possible.

3. What have you tried to fix the issue?
I tired using comma between option/text like "finance,hr" but it did not work.

4. Upload any forms or screenshots you can share publicly below.
The above screenshot take from ODK Docs choice filter section.

Thanks in advance for helping.

Hi @Muhammad :smile:

You can try something like:

Choices Sheet

list_name name label category category2
job_titles training Training hr finance

Survey Sheet

type name label choice_filter
select_one job_titles job_title Job Title category=${job_category} or category2=${job_category}

Great day ahead! :smile:

1 Like

Thanks @MinimalPotato for the answer

My issue is in some cases the category column will be like category1, category2, category3 and so on.

Plus I have two more attributes (State, Region, District) with similar issues, thus, if I apply this solution, I might have to deal with 9 columns.

Have a nice day.

Hmm, I guess you can even try something like this.. :thinking:

Choices Sheet

list_name name label category
job_titles training Training hr,finance

Survey Sheet

type name label choice_filter
select_one job_titles job_title Job Title contains(category, ${job_category})

I haven't tried it for myself, but i feel like it will work. Do let me know! :smile:

2 Likes

Yes, that would work! You just need to be very careful that the name of one category isn't contained in the name of another. For example, if you have hr_recruitment as a job category, it will match a contains filter for hr.

If you do need to have overlapping names, you can space-separate them like finance hr_recruitment and then use the selected function. If you have something like selected(category, ${job_category} and the value for ${job_category} is hr, it will NOT be identified as selected in the space-separated list above.

3 Likes

Ah! Thanks @LN ! :smile:
Never knew we could use "selected" over space separated sub-strings, it will definitely be a better way than using "contains" when dealing with overlapping names! :smile:

2 Likes