Survey123 If/Then relevant question

851
3
02-23-2018 10:59 AM
Highlighted
New Contributor II

I have a survey under construction that has multiple select_one yes_no questions.

  1. Is there this thing present? Y/N
  2. Is there this other thing present? Y/N
  3. What about this thing? Y/N

etc....

I'm trying to have a final field that is triggered for follow up. 

"If any question 1-7 above was answered Yes, then follow up is required and it needs to default as yes." 

I currently have it set up as a relevant question, but would rather have it autopopulate to "yes" and have it read only. 

I've poured over the other if/then questions on the forum# and cant' seem to find a solution. 

Reply
0 Kudos
3 Replies
Highlighted
Esri Esteemed Contributor

Hi John,

This can be done in a few ways.  As you mention above, you could nest a series of if statements to evaluate whether  'yes' is selected.  In this case, because you only need to identify the presence of one 'yes', I might suggest concatenating the questions together and using a regex to find the value 'yes' (or whatever the yes value is), and then using it in an if statement to set yes or no:

if(regex(concat(${q1}, ${q2}, ${q3}, ${q4}, ${q5}, ${q6}, ${q7}), '^.*yes.*$'), 'yes', 'no')

Highlighted
New Contributor III

Hi James,

I need to do this as well, but instead of a series of questions, I have a Yes/No question in a repeat ${CaptureYN}.  If the answer is ever "Yes" to ${CaptureYN}, I want to make the answer to a select_one yes/no question named ${SubmitSnake} Yes.  Will this work for a question in a repeat?

if(regex(concat(${CaptureYN}, '^.*Yes.*$'), 'Yes', 'No'))

When I try this calculation, I get an error that it "cannot handle function 'if'. Requires 3 arguments. Only 1 provided.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Amy,

Check the placement of the parenthesis- you should have 2 at the end of the regex.  Instead of the concat(), I would suggest the sum() function, which will concatenate strings from a repeat in the app.  Also, check if you are storing 'Yes' or 'yes' (in fact, given this is yes/no, you could just check for 'y', 'e', or 's').

Reply
0 Kudos