HOW TO
In ArcGIS Online, custom expressions written in the Arcade expression language can be used to configure pop-ups. Expressions can be used to generate new data with a reference to an existing field in a layer that has multiple values.
This article provides the steps to return the highest and lowest values in a field of a pop-up via ArcGIS Online Map Viewer. In this example, two new fields (Low Ratio Year(s) and Top Ratio Year(s)) are added to the pop-up by using the Ratio of Female to Male in Primary Education, 2006 to 2016 fields, as reference to display the lowest and highest ratio years for each point symbol.
Note: The data displayed in ArcGIS Online may have additional decimals that are rounded in the table by default.
//specify the field names to reference to var <variableName1> = [ $feature.<field_Name1>, $feature.<field_Name2>, $feature.<field_Name3>, $feature.<field_Name4>, $feature.<field_Name5>, $feature.<field_Name6>, $feature.<field_Name7>, $feature.<field_Name8>, $feature.<field_Name9>, $feature.<field_Name10>, $feature.<field_Name11> ] var <variableName2> = Max(<variableName1>) var <variableName3> = [] //Assigning the highest value for (var <v> in <variableName1>){ if (<variableName1>[<v>] == <variableName2>){ var <variableName4> = Decode( <v>, 0, '<field_display_Name1>', 1, '<field_display_Name2>', 2, '<field_display_Name3>', 3, '<field_display_Name4>', 4, '<field_display_Name5>', 5, '<field_display_Name6>', 6, '<field_display_Name7>', 7, '<field_display_Name8>', 8, '<field_display_Name9>', 9, '<field_display_Name10>', 10, '<field_display_Name11>', '' ) Push(<variableName3>, <variableName4>) } } return Concatenate(<variableName3>, TextFormatting.NewLine)
//specify the field names to reference to var <variableName1> = [ $feature.<field_Name1>, $feature.<field_Name2>, $feature.<field_Name3>, $feature.<field_Name4>, $feature.<field_Name5>, $feature.<field_Name6>, $feature.<field_Name7>, $feature.<field_Name8>, $feature.<field_Name9>, $feature.<field_Name10>, $feature.<field_Name11> ] var <variableName2> = Min(<variableName1>) var <variableName3> = [] //Assigning the lowest value for (var <v> in <variableName1>){ if (<variableName1>[<v>] == <variableName2>){ var <variableName4> = Decode( <v>, 0, '<field_display_Name1>', 1, '<field_display_Name2>', 2, '<field_display_Name3>', 3, '<field_display_Name4>', 4, '<field_display_Name5>', 5, '<field_display_Name6>', 6, '<field_display_Name7>', 7, '<field_display_Name8>', 8, '<field_display_Name9>', 9, '<field_display_Name10>', 10, '<field_display_Name11>', '' ) Push(<variableName3>, <variableName4>) } } return Concatenate(<variableName3>, TextFormatting.NewLine)
The image below demonstrates the pop-up display without the Arcade expression.
The image below demonstrates the pop-up display with the Arcade expression.
Get help from ArcGIS experts
Download the Esri Support App