Survey123 Using Conditional Calculations to auto-populate fields

2799
10
02-17-2018 07:24 AM
Highlighted
Occasional Contributor

Hello,

I am working on a utility pole inspection form that will have multiple questions and am trying to figure a way to create a shortcut field (Quick_Pick) that will auto populate these questions when either everything is Okay or they cannot inspect the pole while still allowing them to choose other answers if needed.  So far I have the following questions setup.  Both fields are select_one type with their corresponding choice lists.

Field Name               Choices

Quick_Pick               "OK" or "No Inspect"

Pole_Condition        "OK" or null

Ive been hacking around trying to create a calculation on the Pole_Condition field without any success.  Below is my latest failed attempt.  Is what I'm trying to do even possible and if so what am I doing wrong?  Any help would be appreciated!

if(selected(${Quick_Pick},'OK'),'OK', or selected(${Quick_Pick}, 'No_Inspect'), 'null')

Josh

Tags (2)
Reply
0 Kudos
10 Replies
Highlighted
Esri Regular Contributor

Hi Josh

If I understand you correctly - you want to update pole_condition based on the answer in quick_pick. If so then the following should work:

 if(selected(${Quick_Pick},'ok'),'OK', if(selected(${Quick_Pick},'no_inspect'),'null', ''))

- if you select OK in quick_pick then we will select ok in pole_condition

- else if you select no_inspect in quick_pick then we will select null in pole_condition

- else we return nothing

 

Note that 'null' would be a choice in your list in the above.

I hope this helps

Thanks

John

Reply
0 Kudos
Highlighted
Occasional Contributor

John,

Unfortunately that did not work either. The only way i can get it to work is to turn the field with the calculate statement into a "text" field which of course defeats my purpose.

Josh

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Hi Josh

Sorry - I should have mentioned that calculations in select_one questions are not currently supported. The good news is that they will be at 2.7 and you can test the functionality out in the Early Adopter Community now.

Thanks

John

Reply
0 Kudos
Highlighted
New Contributor III

Hi John,

I'm working with version 2.7.72 now and i'm unable to get my calculation on a select_one to work.  I want my select_one to pick "Not Started" if any of my other questions = "yes".  i had this working as a hidden text field no problem, but we'd like to update this status field after the initial survey is collected.  I haven't been able to find an example of how to accomplish this, i hope you can help.
Thanks!
Sue

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Hi Sue

Please see attached

Thanks

John

Highlighted
New Contributor III

Thanks Johnathan, I was able to get this to work!

Highlighted
New Contributor III

Is it possible to use multiple questions to auto fill a question?  I've got a couple of inspection forms where it will say something along the lines of, "A 'No' to any of questions 1-5 results in a Failed inspection."  I'm using Survey123 Connect version 2.4.6 (not able to upgrade without admin approval).  I've got it set up as a select one and for right now that's fine, but if I can automate out any human error that would be great.

Would something like this work?  I'm not sure how to add multiple conditions.

if(selected(${Q1}and${Q2}and${Q3}and${Q4}and${Q5},'Yes'),'Pass', if(selected(${Q1}or${Q2}or${Q3}or${Q4}or${Q5},'No'),'Fail', ''))

Thanks!

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Tim,

Each question should be evaluated in their own selected() function and joined.  In your case, if you want Q1-5 to be 'Yes', you do not need the second set of evaluations:

if(selected(${Q1}, 'Yes') and selected(${Q2}, 'Yes') and selected(${Q3}'Yes') and selected(${Q4}'Yes') and selected(${Q5},'Yes'), 'Pass', 'Fail')

Highlighted
New Contributor III

James this worked perfectly, thank you!

Reply
0 Kudos