HOW TO

Group unique values from multiple attribute fields using Arcade expressions in ArcGIS Online and Portal for ArcGIS Map Viewer

Last Published: February 23, 2023

Summary

In ArcGIS Online and Portal for ArcGIS Map Viewer, the symbology on the map can be configured to group multiple attribute fields according to the specified conditions using Arcade expressions. This makes certain aspects of the data easily distinguishable when presenting point features on a map.

This article provides the instructions to use Arcade expressions to group unique values from multiple attribute fields in Map Viewer.

The image below shows a map in ArcGIS Online Map Viewer with the default styling point symbology.

The ArcGIS Online Map Viewer map with the default styling point features

Procedure

  1. Open the map in Map Viewer. Click Layers, and select the layer for editing.
  2. On the Settings (light) toolbar, click Styles > + Expression to open the Arcade Expression dialog box.
  3. In the editor window, specify a name for the new expression.
  4. In the Expression dialog box, insert the following Arcade expression.
    1. Define a variable for each field. In this example, two variables are defined to represent the corresponding field.
var <variableName1> = $feature.<fieldName1>
var <variableName2> = $feature.<fieldName2>
  1. Specify the following If and else statement to execute if a condition evaluates to 'true' or 'false'.

if(<variableName1> == "<domainNameOrFieldValue1>")
{
    if(<variableName2> == "<domainNameOrFieldValue2>")
    {
      return "<groupName1>"
    }
}

if(<variableName1> == "<domainNameOrFieldValue1>")
{
    if(<variableName2> == "<domainNameOrFieldValue3>")
    {
      return "<groupName2>"
    }
}

else
{
  return "<groupName3>"
}

The code block below is an example of the full working expression.

var bObtain = $feature.BandObtained
var bColor = $feature.BandColor

if(bObtain == "HS")
{
    if(bColor == "G")
    {
      return "Group 1"
    }
}

if(bObtain == "HS")
{
    if(bColor == "S")
    {
        return "Group 2"
    }
}

else
{
    return "Group 3"
}
  1. Click Run to view a preview of the expression result. If the required result is achieved, click Done.
Specifying the Arcade expression and renaming the expression in the ArcGIS Online Map Viewer Arcade Expression dialog box
  1. In the Styles pane under the Pick a style section, click Style options.
The Styles pane in ArcGIS Online Map Viewer
  1. Click the color ramp under Symbol style to apply further changes to the symbol style.
  2. Click Done to close the Style options pane.
The Style options pane in ArcGIS Online Map Viewer
  1. Click Done to close the Styles pane.

The image below shows the groups of unique values customized according to the steps above.

A map in ArcGIS Online Map Viewer with three groups of multiple attribute fields

Article ID: 000029178

Software:
  • ArcGIS Online
  • Portal for ArcGIS

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