Cascading selects: Filtering multiple-choice option lists
To open or use this sample form, go to the Design tab, scroll down to the Your forms and datasets section, and click + then Start new form; then enable Use a sample form as your starting point and choose Cascading selects: Filtering multiple-choice option lists from the list. You can also click here to download the spreadsheet form definition.
When you open the spreadsheet form definition, you will see a series of three multiple-choice questions in the middle of the form:
type | name | label | choice_filter |
select_one region | survey_region | In which region are you filling out this survey? | |
select_one country | survey_country | In which country? | filter=${survey_region} |
select_one city | survey_city | In which city? | filter=${survey_country} |
You may need to scroll right to find the choice_filter column, which is highlighted in orange. For any select_one or select_multiple field, the expression in this column specifies how to filter the available choices based on earlier responses (see Dynamically filtering lists of multiple-choice options for a complete discussion).
In this form, the choices sheet, which lists all possible answer options for multiple-choice questions, has an additional filter column:
list_name | value | label | filter |
region | AF | Africa | |
region | SA | South Asia | |
country | ZW | Zimbabwe | AF |
country | ZA | South Africa | AF |
country | IN | India | SA |
country | BD | Bangladesh | SA |
city | Harare | Harare | ZW |
city | Bulawayo | Bulawayo | ZW |
city | Pretoria | Pretoria | ZA |
city | Cape_Town | Cape Town | ZA |
city | New_Delhi | New Delhi | IN |
city | Chennai | Chennai | IN |
city | Dhaka | Dhaka | BD |
city | Chittagong | Chittagong | BD |
The values in that filter column are referenced in the choice_filter expressions on the survey sheet, so the expressions and the values work hand-in-hand. So, for example, the choice_filter expression for the "In which country (are you filling out this survey)?" question is "filter=${survey_region}", and the filter values for the country options are "AF" and "SA", which match the values for the region choice options.
If the user selects "South Asia" for region, for example, then this is the next question that will appear:
And if the user then selects "Bangladesh", this will be the next question:
If the user instead selects "Africa" as the region, this is how the next question will appear:
And if the user then selects "South Africa", this will be the next question:
You can see that the questions remain constant; the only things that change are the answer options, which are filtered based on previous responses.