Survey123 If Statements

1844
5
Jump to solution
05-23-2018 11:51 AM
Highlighted
Occasional Contributor III

I have a field with a select_one type. How can I default text into fields based on the select_one choice? I tried looking into If statements but I couldn't find anything.

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Esteemed Contributor

Hi Jordan,

The selected() function is used to create a condition that is then used by an if() function to set the value:

if(selected(${CALLTYPE}, 'CarbonMonoxide'), 'X', 'Not Carbon Monoxide')

View solution in original post

5 Replies
Highlighted
Esri Esteemed Contributor

Hi Jordan,

You can calculate field based on previous answers.  In the case of a select_one question, you can use either an = to check (ex: ${q} = 'a') or use the selected() function (ex: selected(${q}, 'a') ) as the evaluation part of an if() statement. Note that both values when the statement is true and when the statement is false are needed.  Formulas—Survey123 for ArcGIS | ArcGIS provides more documentation.

Reply
0 Kudos
Highlighted
Occasional Contributor III

This doesn't work but how do I default the field to X text? I don't see anywhere in the formula's to populate a value when another field is selected.

select(${CALLTYPE},'CarbonMonoxide', = 'X')

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Jordan,

The selected() function is used to create a condition that is then used by an if() function to set the value:

if(selected(${CALLTYPE}, 'CarbonMonoxide'), 'X', 'Not Carbon Monoxide')

View solution in original post

Highlighted
Occasional Contributor III

Thanks! If anyone comes across this formula please make sure you place it in the "Calculations" field and not the relevant field because nothing will happen. 

Reply
0 Kudos
Highlighted
by
Occasional Contributor III

if(${wradio_current} ='A', 'None', if(${wradio_current} ='B', 'None', 'user input from select_one'))

Is there a way to let the user input the else value?

Reply
0 Kudos