Ask Question only after satisfying the condition

Hello ODK

How can we ask the Question only after satisfying many conditions?

Note: Ask this question if Q3= 2 or 4 and Q8 = 5

Q10. What is your name?


Put this condition in Relevance (in Q10)
(in ODK Build)
(/data/Q3 ='2' and /data/Q8 ='5') or (/data/Q3 ='4' and /data/Q8 ='5')

Hi @sanish_shrestha, yes it is possible, all you have to do is to make the Q10 question relevance if it meet your condition in Q3. example: relevance = ${Q3 question_name} = 2 or ${Q3 question_name} = 4 or ${Q5 question_name} = 5.

with the above example if Q3 = 2, Q10 will be relevant and same to the others.


Thank you Fabla ,
but i think he need the conditions
Note: Ask this question if Q3= 2 or 4 and Q8 = 5
so the conditions :
(/data/Q3 =‘2’ and /data/Q8 =‘5’) or (/data/Q3 =‘4’ and /data/Q8 =‘5’)

1 Like

Hi @sanish_shrestha

please look at this example: form_relevant.xlsx (9.8 KB)


1 Like

The below method (found in the above example form) works for referencing a 'select_one' or 'integer' type.

(${q1}=2 or ${q1}=4) and ${q2}=5

However if you are referencing 'select_multiple' types this method will not work as expected. For example if q1 was a 'select_multiple' and you wanted q3 to be relevant if q1 was equal to 1 or 2 it should be written as

selected(${q1},'1') or selected(${q1},'2')

I highlight this because this was an error I made all the time when first designing xlsforms.