Survey123 If Statements

4535
5
Jump to solution
05-23-2018 11:51 AM
JordanMiller4
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)
0 Kudos
1 Solution

Accepted Solutions
JamesTedrick
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
JamesTedrick
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.

0 Kudos
JordanMiller4
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')

0 Kudos
JamesTedrick
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')

JordanMiller4
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. 

0 Kudos
TL2
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?