Select to view content in your preferred language

Survey123 Choice Filter from integer field

133
2
2 weeks ago
sarahebell007
New Contributor

I am trying to prepopulate a select_one field based off the answer to an integer field and need some help with the coding.

For context: I want the grade of a tree (saw, tie, or pulp) to be automatically populated based off the Diameter (DBH) that is entered. However, the user still needs to be able to change it manually if needed.

Saw grade = 16"+

Tie = 12-16"

Pulp = 6-12"

So if the DBH entered is 13", I want the Grade to pop up as Tie.

I am using Survey123 Connect. I read through Esri posts and general Google posts on choice filters and cascading selects and couldn't find info on integer to select_one filters. All the ones I saw were for the other way around. I know I need to set up if-then statements using the dbh classes as constraints, but the exact language and what columns to use is the issue.

Any help would be appreciated!

0 Kudos
2 Replies
MobiusSnake
MVP Regular Contributor

You can use a calculation with a few nested "if" statements for this.  Assuming you're tracking DBH as integers, and your select list looks like this:

MobiusSnake_0-1761262533686.png

You could have a "select_one grade" question with this calculation on it:

if(${dbh_cm} >= 6, if(${dbh_cm} < 12, 'Pulp', if(${dbh_cm} < 16, 'Tie', 'Saw')), '')

This should automatically calculate a value when the users punch in the DBH, but it will allow them to change that selection.  If they enter a new DBH value, it'll recalculate.

Edit - Made one small change, the first '>' in the calculation should be '>='

sarahebell007
New Contributor

Solution:

if(${dbh} >= 16, 'saw', if(${dbh} >= 13.0 and ${dbh} <= 16, 'tie', if(${dbh} >= 6 and ${dbh} <= 12, 'pulp', 'other')))

In the calculation column of the select_one field.

Thank you for the help!

 

 

0 Kudos