How Can I combine multiple conditions and if it doesn't find to find in another condition in Survey123 connect?

09-23-2020 05:34 AM
New Contributor

In fact, I have a form with different conditions. A person has to select or combine many questions by answering. Let's say a person has an age of 30 even above it and is positive and is responsible and is having diabete to say it qualifies Yes for an answer. Here you have to use and to combine not ot as it appears in NESTING IF Conditions. So if that condition is not the one he has answered by ticking let's say he is not responsible from above can give Yes as an answer. How to do nested if conditions with and by combining many things to give One answer if selected together not or as it is seemed for nested conditions and if not found to look up for another condition or to nest in other to give the same value for "Yes". Thanks.

0 Kudos
1 Reply
Esri Notable Contributor

The if condition may help: Quick reference—ArcGIS Survey123 | Documentation 

if(condition, a, b)  If true, returns a; otherwise, returns b.

if(selected(${question_one}, 'yes') and selected(${question_two}, 'yes'), 'yes', 'no')

You can nest if expressions. For example:

if(selected(${question_one}, 'yes') and selected(${question_two}, 'yes'), 'yes', if(selected(${question_one}, 'yes') and selected(${question_three}, 'yes'), 'yes', 'no'))

Using the XLSForm if condition can lead into very hard to read expressions quickly. Alternatively, using JavaScript syntax may help you build more complex conditions and keep the code more readable. 

0 Kudos