Select multiple with relevant option

What is the problem? Please be detailed.
I need to add a Select multiple question with relevant option.
Example : do you have any of these disease ? Diabetes, asthma , heart disease , non of the above.
And the next questions is ( do you take any medication for the above disease )
I want this questions to appear if one of the disease was selected

What ODK tool and version are you using? And on what device and operating system version?

What steps can we take to reproduce the problem?
Tried to add relevant with , between option and didn't work

What you have you tried to fix the problem?

Show me please how to do it
Anything else we should know or have? If you have a test form or screenshots or logs, attach here.

Hi @AbrarAlasmari,

Provided the answer to your first question is required, you can try puting under relevant column of your second question not(selected({YourMultipleSelectFieldName}, 'ValueofNonOfTheAboveChoice'))
So it will appear only if the operator chooses one of the listed diseases.

Thanks ,
I tried it but it doesn't work.. it show error ..
Error at the start ( not)


Thanks a lot that was very helpful..
I added $ before the { and it works now

Many thanks

Hi @AbrarAlasmari,

You're right; I forgot the $ sign which should always be there before the first curly bracket when you refer to one of the variables.

Glad I could help.


@Souirji_Abdelghani do you use the same method with select_one? If not what do you use with select_one

Yes, technically you can use the same method - ie selected(${question},'value') - for a select_one, but because with a select_one there is only ever going to be a single result, it's a lot simple just to use ${question}='value'. Basically, with a select_one, you can check the (singular) result just as if it were a regular text question.

[if you want to know the gory details of how multiple selections are represented in XForms, and how the XPath selected() function checks for a specific value in such a result, just lemme know... :wink: ]

1 Like

i would love to know the details

umm. those were the details... :slight_smile:

Basically, for a select_multi you'd need:

relevant = "not(selected(${YourMultipleSelectFieldName}, 'ValueofNonOfTheAboveChoice'))"

whereas for a select_one you could get away with:

relevant = "${Your_SINGLE_SelectFieldName} != 'ValueofNonOfTheAboveChoice' "

[note, I'm mirroring not(selected(...)) here, hence !=, ie not equal]

Got it , i tried with this ${a}!=1 and ${b}!=1 and ${b}=1. This is on a question i want to appear after all those criteria's are met. However its shows me this error "Error: b'ODK Validate Errors:\n>> Something broke the parser. See above for a hint.\nDependency cycles amongst the xpath expressions in relevant/calculate\n\nResult: Invalid" any help?

Can you please post the form that you are having a problem with, and maybe we can better determine the problem.

Please note, ...and ${b}!=1 and ${b}=1 is logically wrong because the expression will always evaluate to false (${b} can never be 1 and not 1 at the same time!). But putting that aside, something else is still causing the fatal 'dependency cycle' error. Hence the need to see the entire form.