PROBLEM

The total value is not calculated if any input field in an ArcGIS Survey123 survey form is blank

Last Published: July 25, 2022

Description

In ArcGIS Survey123 Connect, formulas are used to perform calculations between several inputs to calculate the total value. When the total value field is set to read-only and the calculation column of the total value is specified, specifying all input fields calculates the total value automatically. For example, calculating the total cost of a construction work (total value) based on the price of tiles, pipes, cements, and manpower (input), or determining the population estimate of wildlife in a sanctuary (total value) based on the observation of multiple animal species (input). However, when one of the inputs is left blank, the total value is not calculated.

The image below shows the read-only total value field (Total cost) configured to calculate the sum of several inputs (Admin cost, Finance cost, Legal cost, and Insurance) in the ArcGIS Survey123 Connect XLSForm.

The XLSForm.

The image below shows the ArcGIS Survey123 web form where the total value field (Total cost) is not calculated when one of the inputs (Insurance) is blank.

The web form with the Total cost not being calculated when one of the inputs is blank.

Cause

A blank field is considered a null value. ArcGIS Survey123 does not identify null values in a calculation, so the total value field is not calculated when the input field is blank.

Solution or Workaround

Follow the steps below to create a read-only field that calculates the total value automatically even if the input field is left blank or unanswered.

Set a condition to assume the blank field equals to zero

The total value field is calculated by setting input fields with the 'If' condition. The condition is specified to assume the value of the blank field is zero.

  1. Open ArcGIS Survey123 Connect. Open the desired survey, or create a new survey using the Advanced template.
  2. Create input fields and the total value field using either the decimal or integer type. In this example, the decimal type is used for input fields (Admin cost, Finance cost, Legal cost, and Insurance) and the total value field (Total cost). The total value is the sum of all input.
  3. Configure the survey as follows:
    1. Create a hidden field for every input field. Refer to ArcGIS Survey123: Quick reference for more information on setting the hidden field.
    2. For all hidden fields, specify the following condition in the calculation column:
Note:
Hidden question types are considered as text fields by Survey123 by default, however, users have the option to specify a different field type for hidden questions.
if(${decimal_fieldname}>0, ${decimal_fieldname}, 0)
Note:
If a condition is set in the decimal or integer field instead of the hidden field, the error message, "Error converting XLSForm" is returned.

The error message if a condition is set in the decimal or integer field instead of the hidden field.
  1. For the total value field, select yes in the readonly column, and specify the following expression in the calculation column:
round(number(${hidden_fieldname1}) + number(${hidden_fieldname2}) + number(${hidden_fieldname3}) + ..., number of decimal places)

The image below shows the ArcGIS Survey123 Connect XLSForm configured with conditions and the calculation of the total value.

The XLSForm with the conditions specified for all hidden fields and the calculation expression for Total cost.

The image below shows the ArcGIS Survey123 web form. Although one of the inputs (Insurance) is blank, the total value (Total cost) is calculated.

The web form with the Total cost being calculated although one of the inputs (Insurance) is blank.

Set the default value as zero

By setting the default value to zero, any input field that is unanswered is calculated as zero instead of left blank and stored as a null value.

Note:
The drawbacks of this method are:
• Unless a value is specified in the input field, the number zero always displays on-screen.
• The zero value in the input field must be erased manually before a value can be specified.
• If a user specifies a value in the input field and later decides to leave the field with no specific answer, the user must insert the number zero manually after deleting the input value specified. Failure to do so causes the field to be considered null, and the total value field cannot be calculated.
  1. Open ArcGIS Survey123 Connect. Open the desired survey, or create a new survey using the Advanced template.
  2. For all input fields, set the default column to zero.
  3. For the total value field, select yes in the readonly column, and specify the following expression in the calculation column:
round(${decimal_fieldname1} + ${decimal_fieldname2} + ${decimal_fieldname3} + ..., number of decimal places)

The image below shows the ArcGIS Survey123 Connect XLSForm configured with the default value, and the calculation of the total value.

The XLSForm with the default values being set to zero for all input fields.

The image below shows the ArcGIS Survey123 web form. Since the default value is set to zero, the total value field is still calculated although one of the input fields is unanswered.

The web form with the Total cost being calculated although one of the inputs is not specified.

Article ID: 000022441

Software:
  • ArcGIS Survey123 Connect
  • ArcGIS Survey123 Website

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options