Displaying choices based on previous group (reverse cascading)

In the survey I’m trying to build, there are a few locations and they have services available at said location depending on the categories they fall into (eg. police stations, health centers, etc) but some locations have fewer services than others even if they are within a category. And depending on what the person selects on question 1, I want a restricted list of services to appear in question 2. For example

Which location did you visit?
Location 1
Location 2
Location 3
Location 4
Location 5
Location 6
Location 7
Location 8

What service did you recieve?
Service 1 (Group 1 - Available to locations 1 & 2)
Service 2 (Group 1 - Available to locations 1 & 2)
Service 3 (Group 1 - Available to locations 1 & 2)
Service 4 (Group 1 - Available to locations 1 & 2)
Service 5 (Group 2 - Available to locations 1, 2, & 3)
Service 6 (Group 2 -Available to locations 1, 2, & 3)
Service 7 (Group 3 -Available to locations 4, 5, 6, & 7)
Service 8 (Group 4 -Available to location 8)

So here Group 2 would actually be group 1 but also have 2 additional services, meanwhile Group 3 and 4 have their own distinct services that don’t have any overlap. I’ve build an XLS form that I thought might do this but I get the error “There has been a problem trying to replace ${group1} with the XPath to the survey element named ‘group1’. There is no survey element with this name.” I’d provide the file, but I’m afraid of uploading private info.

However, anyone have an idea of how to build context for something like this within an XLS file by using choice filters/cascading selects?

Thanks in advance!

1 Like

Hi,

You’re correct that you need to use the choice_filter column in your survey sheet. If you wish you could share a small section of your xlsform which doesnt contain any private info by deleting most of the rows in each tab or changing some labels so its meaningless (dont worry if the xlsform becomes non-functional in the process). My advice would be to create a calculated field which converts the location into a group using an if() function and then use that calculated group to filter your choices. The choices should look something like the below screenshot.

image

1 Like

Hi @pashches,

Welcome to the community! You could also try this out apart from what @NoelCartONG has advised.

In the survey tab of your xlsform:

In the choices tab of your xlsform:

Data entry screen as seen in Enekto:

Reference xlsform:
Cascading Select.xlsx (12.0 KB)

Have a great day!

2 Likes

Hi @NoelCartONG,

Welcome to the community! Maybe you could also add to the workaround shared above in a different approach if you have. It should enrich the solutions we document in the community forum (which should benefit the entire KoBoToolbox users).

Have a great day!

Thanks to the both of you for the responses.

I was actually already in the process of trying to implement @NoelCartONG’s solution but I never did the get syntax correctly for the calcultion and the if/or statements it would require. It seemed to me a bit more elegant to assign a location to a group and then call the group once, instead of creating a long lists (in my case was 18 locations in all and creating 1 for each). But anyway, the 18 list thing did work in the end so I’m happy.

Thanks @Kal_Lam!

1 Like