Dynamic List of Household members over 18 years

Hello All,

I am trying to build a form that collects information on all household members and then produces a dynamic list of only those members which are 18 years or older to be used in a select_one for follow up questions.

I have managed to build a list which just excludes the labels for members under 18yrs but cannot work out how to 'compress' the list to only show adults.

The issue is that enumerators could still select the 'blank" labels of children by mistake as it currently stands.

Any advice would be helpful as i have run out of ideas,

Thanks
HHMemberDynamicList.xlsx (159.5 KB)

1 Like

Hi Rusti,

There's actually a much easier way to go about doing this! You can use the results of a question in a repeat to directly generate the choices for a select question (see the docs: https://docs.getodk.org/form-logic/#generating-select-ones-from-repeats).

In your case, what you'd want to do is change your respondent select to select_one ${Calc_HHName}. This will then create a select question with the choices composed of all the names entered in the repeat.

Now all we have to do is filter the options! We can add a choice_filter column to the survey worksheet to facilitate this, and then filter by age. In your case, this looks like ${Calc_Age} >= 18 as the expression placed in the choice_filter. This results in the select_one question only offering the names of people who are 18 or over as options. You can read more about choice filters in the docs here: https://docs.getodk.org/form-logic/#filtering-options-in-select-questions

Here's a working version of this form:
HHMemberDynamicList.xlsx (158.3 KB)
(Note that I did remove the field-list group inside the repeat, as that was giving me an unrelated parse error). You can accomplish the same effect by applying field-list to the repeat itself.

1 Like

Hi Justin,
Thanks so much for the help, it looks great, much appreciated. Regards

2 Likes