how do I provide a default value based on a response to a previous question

1063
6
Jump to solution
06-22-2017 04:45 AM
Highlighted
New Contributor III

I have a survey that contains a "select_one" where I use a choice list to pick a code.

I then have a subsequent field which I want to populate with a default value based on the previous response, but I want to have the option to overwrite the default value presented.

Is there a simple way to achieve this?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Esteemed Contributor

A lookup can be done with an if statement with the values inline; additionally the pulldata() function can look up values from an accompanying CSV file - see Formulas—Survey123 for ArcGIS | ArcGIS (Working with External Content)

View solution in original post

6 Replies
Highlighted
Esri Esteemed Contributor

Hi,

In Survey123 terms, what you are asking for is to calculate a value based on a previous question.  You can do this in the calculation column - see Formulas—Survey123 for ArcGIS | ArcGIS .  A calculation will still allow a value to be manually overridden.

0 Kudos
Highlighted
New Contributor III

Hi James,

so... I don't want to e.g. multiply the answer to a previous question by a factor.. I want to use the answer to the previous question to provide a look-up.  Would this be achieved using an a nested if statement in the calculation field?

0 Kudos
Highlighted
Esri Esteemed Contributor

A lookup can be done with an if statement with the values inline; additionally the pulldata() function can look up values from an accompanying CSV file - see Formulas—Survey123 for ArcGIS | ArcGIS (Working with External Content)

View solution in original post

Highlighted
Esri Contributor

Hello James,

When populating answer of a select_one question (Q2) based on answer of a previous question (Q1), a 'recalculate' button appears for Q2 when user select an option in Q1 except one that used to populate Q2.

In the example below, Q2 has this statement in the calculation: if(selected(${question1},'option1'),'option1',''), and Q3 is using pulldata() to achieve the same functionality, they both work for my intention. i.e. Select option 1 in Q1, then Q2 and Q3 will have option 1 selected automatically.

 

Bur if I select option 2 in Q1, the 'recalculate' buttons appears for Q2 and Q3 no matter what I select. 

  

Am I doing something wrong or will I be able to disable those buttons in the setting? 

Many thanks.

Cheers,

Sun

0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Jing,

You're not doing anything wrong- your calculations are working exactly as designed.  Remember that a calculation *must* return a value; there isn't a 'leave everything just as it is' concept.  In this case, when you select option2 in q1, you are calculating q2 to an empty value; the recalculation symbol showing when another value is present reflects that.  Similarly, an empty search would also be calculating q3 to an empty value.

Highlighted
Esri Contributor

Hello James,

Thank you for your helpful information!

Cheers,

Sun

0 Kudos