How To: Calculate the sum of repeats in Survey123 for ArcGIS
Calculating the sum of repeats enables users to summarize the total value across multiple repeat questions answered in the same parent record. For example, to record the total items inspected during an asset inspection, to determine the total volume of chemical waste disposed by a chemical facility, or to identify the total tonnage of recyclable material collected from a residential area.
In this example, the repeat section comprises the details of items collected from a few warehouses. The details of one item type is filled in one repeat record. The sum() function is used to calculate the total number of items and the total number of boxes collected from multiple repeat records based on the item types collected.
The sum of repeats is calculated using the sum() function outside the repeat section. Follow the steps below to calculate the sum of repeats in Survey123 for ArcGIS:
- Open Survey123 Connect for ArcGIS and create a survey using an Advanced template.
- Click the Open XLSForm spreadsheet icon to open the Excel form.
- Configure the form to contain a repeat section.
- Outside the repeat section, create an integer or decimal type question. In the calculation column, use the sum() function to calculate the sum of repeats.
The image below shows the sum() function configured in the calculation column outside the repeat section. The sum() function is used to calculate the total number of items and the total number of boxes collected based on the details provided in the repeat records.
Note: Other aggregate functions such as count(), max(), and min() can also be calculated from the repeat records. These functions work with repeats within the same parent record, and not across repeat records in the survey.
- Save the Excel form and publish the survey.
The image below shows the sum of all repeats calculated automatically in the survey form.
When viewing the hosted feature layer in Map Viewer, the attribute table shows the sum of repeats and other aggregate functions configured in the survey form. The image below shows the sum of items and boxes collected in a single survey response with three repeat records.
The individual records of each repeat record are stored in the related record table. The image below shows the details of the three repeat records sent in the single survey response. The Total items collected column in the attribute table is calculated based on the sum of the Number of items collected column in this related record table.
- Survey123 for ArcGIS: Formulas
- GeoNet: World Milk Day Release (2.1)
- GeoNet: Calculating a final total from repeats, Survey123?
- GeoNet: count() and sum() functions for repeat in Inbox
- GeoNet: Survey123 built-in functions