How to make relevant row show up based on specific choices

Hello,
The code in the relevant column works well:

${Q21} ='1'
${Q21} ='2'
${Q21} ='3'

This also works well:

(selected(${Q21},'1') and selected(${Q21},'2'))
(selected(${Q21},'1') and selected(${Q21},'3'))
(selected(${Q21},'2') and selected(${Q21},'3'))

When select '1' and '2' and '3' in Q21, I expect the row with this code to show up:

(selected(${Q21},'1') and selected(${Q21},'2')  and selected(${Q21},'3'))

The problem is that the following rows with its perspective code up show up when I select '1' and '2' and '3' in Q21:

(selected(${Q21},'1') and selected(${Q21},'2'))
(selected(${Q21},'1') and selected(${Q21},'3'))
(selected(${Q21},'2') and selected(${Q21},'3'))
(selected(${Q21},'1') and selected(${Q21},'2')  and selected(${Q21},'3'))

Insight on how to make sure only :(selected(${Q21},'1') and selected(${Q21},'2') and selected(${Q21},'3')) shows up when I select '1' and '2' and '3' will be appreciated.

Hi @ania, and wolcome to the ODK Community forum !
Please take some time to introduce yourself here :slight_smile:

In fact when you select 1 and 2 and 3, the "1 and 2" condition is true, as "1 and 3" and "2 and 3". You need to add a not(selected(${Q21},'value to exclude')) to the test where only 2 values are needed

@mathieubossaert Thank you for the suggestion. Could you kindly clarify this statement 'to the test where only 2 values are needed' ? I tried adding not(selected(${Q21},'value to exclude')) to the rows where 2 conditions are.

If you want to show an item only if values 1 and 2 are selected and not when 1 and 2 and 3 are selected, your relevant test should look like :
selected(${Q21},'1') and selected(${Q21},'2') AND not(selected(${Q21},'3')

Thank you for the clarification, it worked perfectly!

1 Like