Select to view content in your preferred language

Trouble with multiple If statements in Survey123 Connect

1431
6
06-12-2020 12:09 PM
CoyeBurnett
Emerging Contributor

Hi there, I'm new to coding for survey 123 and I was wondering if someone could help me out. 

I'm basically trying to create a check on a goshawk survey form to prevent conflicting data being entered. I want this check to be based on the response choice from two separate "select one" labels. Here is the example:

If the "yes" choice is selected for the "UTMs Accurate?" label, and the "unknown" choice is selected for the "Is nest Active?" label I want to be able generate a sub label with the question "Did you find the nest?" with a "yes" or "no" choice.

Is it possible for a response prompt like this to be activated only when two choices from two separate labels are selected? Or am I better off just generating that response when only one of the choices is selected?

Thanks for the help!

0 Kudos
6 Replies
DougBrowning
MVP Esteemed Contributor

Yes easy.  if(q1=something and q2=something, yes, no)

Is that what you mean?

0 Kudos
Hussam_AlJabri
Frequent Contributor

Hi  Coye Burnett,

 

Yes it is possible by set the relevant in the question "Did you find the nest?"

selected(${UTMs_Accurate},'yes') and selected(${nest_Active},'unknown')

 

 

CoyeBurnett
Emerging Contributor

Yes that solved it! Thanks so much.

I am also having trouble with getting a constraint when dealing with multiple select_one categories to co-operate. This time I'm looking for a constraint only when both 'Yes' is selected in the 'UTMs_Accurate' field and when 'Unknown' is selected in the 'tree_tagged' field. So far with this formula: selected(${utm_acc},'Y_accurate'), selected(${tree_tag},'Unk_tag') I'm constraining everything BUT this combination, which is the opposite of what I want to do. Basically I'm trying to prohibit this combination without having to add every single combination but the one I'm trying to avoid. 

I figured that I probably need to include an "if" statement within this formula but everything that I have tried has just ended up either allowing all combinations or constraining all combinations. 

I would so appreciate your help again!

0 Kudos
Hussam_AlJabri
Frequent Contributor

Could you please share a snapshot of your xlsform so I will get you clearly!

I understood that if you select "Yes" in (UTMs_Accurate) the second question should not select "Unknown".

if my understanding is correct.. You need to write this formula in the constraint column:

if(${utm_acc}='Y_accurate',${tree_tag}!='Unk_tag','k_tag')

CoyeBurnett
Emerging Contributor

Thank you Hussam! That actually took care of it. I thought I had to include "selected" within the formula before the field names, which is what was causing me grief. But this formula works perfectly!

Hussam_AlJabri
Frequent Contributor

I'm happy that works with you. Keep it up with the amazing application that let our organizations work smartly! 

0 Kudos