How do you build a 'relevant' for a multiple-choice question?

Hello everyone. I use this line of code ${id_activity_1_1}<=1019 in the ‘Relevant’ to show or hide a question in the form I build; the question id_activity is multiple, and when I select more than one option, the question is hidden. How should the ‘Relevant’ be built? . Please

Welcome @celkristi,

  • For select_multiple, you always need to use selected(…). See Form Operators and Functions - ODK Docs
  • All choice names are stored as strings.
  • Multiple choices are stored in a string, separated by one space. So, you cannot directly use a mathematic comparison like <= .
    So, it will be: selected($}YourSelectMultipleName}, ‘Value1’) or selected($}YourSelectMultipleName}, ‘Value2’) …

There is also a more complex option using the max() function…

General hint: Don’t forget, please, to check your form with the Online validator during development and before deployment. The Help Center articles and the search function of this form can often provide help and examples.

1 Like

@celkristi, these community posts discussed previously should help you understand your issue with various workarounds.

Thanks, the new relevant is this one, it works perfect for me.
selected(${id_activity_1_1}, ‘1011’) or
selected(${id_activity_1_1}, ‘1012’) or
selected(${id_activity_1_1}, ‘1013’) or
selected(${id_activity_1_1}, ‘1014’) or
selected(${id_activity_1_1}, ‘1015’) or
selected(${id_activity_1_1}, ‘1016’) or
selected(${id_activity_1_1}, ‘1017’) or
selected(${id_activity_1_1}, ‘1018’) or
selected(${id_activity_1_1}, ‘1019’)

2 Likes