How to add relevant tests in Build

Hello,
I have a question regarding the logic (rules) of the questionnaire.
I'm using odk build and I need question 4 to appear only if the answer to question 2 is "Other" (value 3).
I tried to use in the Relevance field in question 4 the following codes:

(selected (national, '3'))
$ {national} = '3'

relevant = "(selected (national, '3'))"
relevant = "$ {national} = '3'"

None worked. Is it possible to do what I need?

Thank you

1 Like

Try with:

selected(${national},'3')

The ${} syntax is introduced by XLSForm. If you are using Build, you will use XPath syntax. For example, if you're using a select one, you can use /data/national = 3. If you are using a select multiple you can use selected(/data/national, 3).

5 Likes

Worth it!
Thank you all.

Hi Hélene, what the syntax would look like in ODK build if I am using a select multiple and I want to use relevant if two options are chosen? Thank you,

Try:

relevant="count-selected(${my_multi_select})=2"

See count-selected() for details.

Thank you Xiphware, what would be the syntax if I am using ODK build and not XML?

per @LN 's earlier response, ${my_multi_select} is the XLSForm syntax, whereas ODK Build directly uses XML, which will instead be something like "/data/my_multi_select" , assuming that "my_multi_select" is the Data Name you used to identify your select multiple question. Note, if this question is located within a group, you'll also have to include the group id in the path, eg "/data/my_group/my_multi_select"