HOW TO

Populate answers in a field based on the value of the previous question in ArcGIS Survey123 Connect

Last Published: March 10, 2023

Summary

In some instances, a field requires multiple formulas to populate answers based on the value in the previous question. Below are three examples of the ways to achieve this using ArcGIS Survey123 Connect.

Procedure

Populate the power of a meter calculated from a formula based on the type of meter selected

In this example, the power of a meter is calculated using two different formulas based on the type of meter selected. The IF function is used to calculate the correct formula based on the type of meter selected.

  1. In ArcGIS Survey123 Connect, open the survey's XLSForm.
  2. Create and configure a select_one question.
    1. In the survey worksheet, in the type column, select select_one and specify the choices list name. In this example, the choices list name is ‘meter’.
    2. Specify the values in the name and label columns. In this example, the question is named ‘themeter' and labeled 'Meter Type.'
Configuration of select_one type question for example 1.
  1. Navigate to the bottom of the worksheet and click the choices tab to open the choices worksheet.
    1. In the list_name column, specify the choices list name created in Step 2a.
    2. In the name column, specify the name of the choices. In this example, ‘With CT’ and ‘Without CT’ are used.
    3. In the label column, specify the value to be displayed in the survey. In this example ‘With CT’ and ‘Without CT’ are used.
Configuration of the list choices for example 1.
  1. Create and configure numerical questions with the multiple formula components.
    1. In the survey worksheet, in the type column, select either the integer or decimal question type. In this example, ‘integer’ is selected.
    2. Specify the values in the name and label columns. In this example, the question is named ‘seconds1' and labeled 'Seconds1.'
    3. Repeat Steps 3a and 3b as many times as required to form the multiple formulas. In this example, another integer question is created and configured. The second integer question is named ‘factor’ and labeled ‘Factor.’
  2. Configure the formula components with the choices.
    1. In the relevant column of the two integer questions, specify the expression of the formula components that are required for the calculations of a meters’ power. Depending on the suitability, use one or both of the following expressions to specify the formula components.
      • This expression is used when the choices share the same formula component.
selected(${select_one fieldname},'<choice 1>') or selected(${select_one fieldname },'<choice 2>')
  • This expression is used when the formula component is only applicable to one choice.
selected(${select_one fieldname},'<choice 1>')
Configured integer questions with formula components for example 1.
  1. Create and configure a numerical question with calculation.
    1. In the survey worksheet, in the type column, select either the integer or decimal question type. In this example, ‘integer’ is selected.
    2. Specify the values in the name and label columns. In this example, the question is named ‘kilowatts' and labeled 'kW.'
    3. In the calculation column of this question, specify the multiple formulas that are to be used as calculations to populate the answers based on the selection of the meter. Use the expression below to specify the formulas.
if(selected(${select_one fieldname },'<choice 1>'),($<formula 1>),($<formula 2>))
Note:
The <formula 1> is the formula used to calculate ‘<choice 1>.'
Numerical question configured with a calculation of multiple formulas for example 1.

The image below displays the populated answers for the power of the meter calculated from the formula based on the type of meter selected in ArcGIS Survey123 Connect.

Multiple answers for kW using multiple formulas based on the type of meter selected in the survey.

Populate the area of a table calculated from two formulas based on the type of shape selected

In this example, the area of a table is calculated using two different formulas based on the type of shape selected. For this example, the Coalesce function is used to calculate the correct formula based on the type of shape selected.

  1. In ArcGIS Survey123 Connect, open the survey's XLSForm.
  2. Create and configure a select_one question.
    1. In the survey worksheet, in the type column, select select_one and specify the choices list name. In this example, the choices list name is ‘shape’.
    2. Specify the values in the name and label columns. In this example, the question is named ‘theshape' and labeled 'Shape of Table.'
Configuration of select_one question type for example 2
  1. Navigate to the bottom of the worksheet and click the choices tab to open the choices worksheet.
    1. In the list_name column, specify the choices list name created in Step 2a.
    2. In the name column, specify the name of the choices. In this example, ‘triangle’ and ‘rectangle’ are used.
    3. In the label column, specify the value to be displayed in the survey. In this example ‘Triangle’ and ‘Rectangle’ are used.
Configuration of the list choices for example 2.
  1. Create and configure numerical questions with the two formula components.
    1. In the survey worksheet, in the type column, select either the integer or decimal question type. In this example, ‘decimal’ is selected.
    2. Specify the values in the name and label columns. In this example, the question is named ‘base' and labeled 'Base.'
    3. Repeat Steps 3a and 3b as many times as required to form the multiple formulas. In this example, another two decimal questions are created and configured.The second decimal question is named ‘height’ and labeled ‘Height.’ The third decimal question is named ‘width’ and labeled ‘Width.’
  2. Configure the formula components with the choices.
    1. In the relevant column of the three decimal questions, specify the expression of the formula components that are required for the calculations of a shape’s area. Depending on the suitability, use one or both of the following expressions to specify the formula components.
      • This expression is used when the choices share the same formula component.
selected(${select_one fieldname},'<choice 1>') or selected(${select_one fieldname },'<choice 2>')
  • This expression is used when the formula component is only applicable to one choice.
selected(${select_one fieldname},'<choice 1>')
Configured integer questions with formula components for example 2.
  1. Create and configure two hidden questions with calculation.
    1. In the survey worksheet, in the type column, select the hidden question type.
    2. Specify the values in the name and label columns. In this example, the question is named ‘area_triangle' and labeled 'at.'
    3. Repeat Steps 2a and 2b as many times as required to form the multiple formulas. In this example, another hidden question is created and configured. The second hidden question is named ‘area_rectangle’ and labeled ‘ar.’
    4. In the calculation column of these questions, specify the formula of each hidden question.
  2. Create and configure a numerical question with calculation.
    1. In the survey worksheet, in the type column, select either the integer or decimal question type. In this example, ‘decimal’ is selected.
    2. Specify the values in the name and label columns. In this example, the question is named ‘thearea' and labeled 'Area.'
    3. In the calculation column of this question, specify the multiple formulas used as calculations to populate the answers based on the selection of the shape. Use the expression below to specify the formulas.
number(coalesce(${<hidden_fieldname1>},${<hidden_fieldname2>}))
Configured hidden and numercal type questions.

Populate the area of a table calculated from multiple formulas based on the type of shape selected

In this example, the area of a table is calculated using two different formulas based on the type of shape selected. The IF function is used to calculate the correct formula based on the type of shape selected.

  1. Follow Steps 1 through 4 from the example above.
  2. Create and configure a numerical question with calculation.
    1. In the survey worksheet, in the type column, select either the integer or decimal question type. In this example, ‘decimal’ is selected.
    2. Specify the values in the name and label columns. In this example, the question is named ‘thearea' and labeled 'Area.'
    3. In the calculation column of this question, specify the multiple formulas that are to be used as calculations to populate the answers based on the selection of the shape. Use the expression below to specify the formulas.
if(selected(${select_one fieldname },'choice1'),($<formula 1>),($<formula 2>))
Numerical question configured with a calculation of multiple formulas for example 2.

The image below displays the populated answers for area calculated from two or multiple formulas based on the type of shape selected in ArcGIS Survey123 Connect.

Multiple answers using multiple formulas in the survey for example 2 and example 3.

Article ID:000029459

Software:
  • ArcGIS Survey123 Connect

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic