HOW TO
In Portal for ArcGIS and ArcGIS Online Map Viewer, Arcade expressions can be used to identify specific fields with similar field names for further calculations.
This article provides an example and instructions for using Arcade expressions to identify and calculate specific fields containing a string in pop-ups of Map Viewer.
In this example, an Arcade expression is used to identify the fields for the Ratio of Female to Male in Primary Education from 2006 to 2009, and calculate the minimum value.
The image below shows a standard pop-up without the minimum value.
var <variableName> = []; var <variableName1> = []; var <variableName2> = Schema($feature)['fields'];
for (var i in <variableName2>){ var <variableName3> = <variableName2>[i] var <variableName4> = <variableName3>['name'] if (Mid(<variableName4>, 5, 1) == '0'){ Push(fields,<variableName4>) Push(<variableName1>, $feature[<variableName4>]) } }
return min(<variableName1>)
Note: Refer to ArcGIS Arcade: Mathematical Functions for other mathematical functions to calculate the given array.
The code below shows the full working script.
var fields = []; var values = []; var all_fields = Schema($feature)['fields']; for (var i in all_fields){ var field_dict = all_fields[i] var x = field_dict['name'] if (Mid(x, 5, 1) == '0'){ Push(fields,x) Push(values, $feature[x]) } } return min(values)
The image below shows the minimum value of the identified fields in the pop-up after using the Arcade expression.
Get help from ArcGIS experts
Download the Esri Support App