HOW TO
ArcGIS Online allows configuring a pop-up of a feature layer with a related table to display related data within the pop-up. However, to calculate and display the sum of multiple attribute fields values in the pop-up, some attribute expressions configurations must be done using Arcade. This article provides the workflow to calculate the sum of multiple attribute fields values in a related table of a feature layer using Arcade to be displayed in a pop-up.
In this example, a hosted feature layer (PolygonParcel) is published in ArcGIS Online with a related table (Relate_19543). The feature layer and the table each have a field named 'FID_Tracts', and they are related based on this field. The image below shows the attribute table of the PolygonParcel feature layer. The related record is presented as a column with an italicized header on the right side of the attribute table.
The image below shows the attributes of the related table, Relate_19543. Value1, Value2, and Value3 are the fields containing the values to be summed up and displayed in the pop-up.
var table = FeatureSetByName($datastore,"<name of related table>") //reads the related table into a variable var total = 0 //define a variable for the sum for (var t in table) {//loop the related table to find the related records for the feature if (t.<the name of the field that the relate is based on> == $feature.<the name of the field that the relate is based on>) { total = total + t.<field name 1> + t.<field name 2> + t.<field name 3> } } return total
Get help from ArcGIS experts
Download the Esri Support App