HOW TO

Customize null value display in map legend using Arcade in ArcGIS Online Map Viewer

First Published: April 17, 2024
Last Published: April 20, 2026

Summary

In ArcGIS Online Map Viewer, when a field symbolized using unique values contains null values, the null values are displayed in the Other category in the ‘Style options’ pane, as shown in the example below.

The null values in the Style options pane

By default, null values cannot be assigned to existing or new groups, and are therefore categorized as Other in the map legend. Arcade expressions can be used to assign custom labels to null records, allowing them to be displayed as descriptive symbology instead of grouped under Other. Arcade can also treat selected non-null values as null for legend display purposes.

The legend below displays the null values in the Other category.

The Other category in the map legend

This article provides the workflow to customize the null value display in the map legend using Arcade in ArcGIS Online Map Viewer.

Procedure

Assign custom labels to null values to display them with symbology labels

  1. In ArcGIS Online, navigate to Content > My content.
  2. Browse to the web map, click More options The More options icon, and select Open in Map Viewer.
  3. In Map Viewer, on the Contents (dark) toolbar, on the Layers tab, click the feature layer.
  4. On the Settings (light) toolbar, click Styles The Styles icon.
  5. In the Styles pane, for Choose attributes, remove any existing expressions or fields and click + Expression.
  1. In the editor window, specify the expression below. Replace <fieldName> with the field name containing null values, <variable name> with the variable, and <Label> with the desired name (in this example, 'Undefined' is used).
var <variable name> = $feature.<fieldName>

When(
   <variable name> == null, '<Label>',
   <variable name>
)

Below is the full working script for this example.

var status = $feature.status_type

When(
  status == null, 'Undefined',
  status
)
The expression in the editor window
  1. Click Done. The null values are assigned the 'Undefined' label in the main category.
The null values with a symbology label in the Style options pane
  1. In the Styles pane, click Done.
  2. On the Contents (dark) toolbar, click Legend The Legend icon to view the legend.
  3. Save the web map.

The Map Viewer legend below shows the null values displayed with the 'Undefined' label.

The null values with a symbology label in the map legend

Assign custom labels to null values and configure non-null values to be treated as null for distinct categorization

  1. In ArcGIS Online, navigate to Content > My content.
  2. Browse to the web map, click More options The More options icon, and select Open in Map Viewer.
  3. In Map Viewer, on the Contents (dark) toolbar, on the Layers tab, click the feature layer.
  4. On the Settings (light) toolbar, click Styles The Styles icon.
  5. In the Styles pane, for Choose attributes, remove any existing expressions or fields, and click + Expression.
  1. In the editor window, specify the expression below. Replace <fieldName> with the field name containing null values, <variable name> with the variable, <Label> with the desired name (in this example, 'Undefined' is used), and <fieldValue1> and <fieldValue2> with the desired field values.
var <variable name> = $feature.<fieldName>

When(
   <variable name> == null, '<Label>', 
   <variable name> == '<fieldValue1>', <variable name>,
   <variable name> == '<fieldValue2>', <variable name>,
  null
)

Below is the full working script for this example. In this example, the Active field value is excluded and assigned as null.

var status = $feature.status_type 

When(
  status == null, 'Undefined', 
  status == 'Warning', status,
  status == 'Inactive', status,
  null
)
The expression in the editor window
  1. Click Done. The non-null value is grouped as a null value in the Other category.
The non-null values are assigned to be null in the Style options pane
  1. In the Styles pane, click Done.
  2. On the Contents (dark) toolbar, click Legend The Legend icon to view the legend.
  3. Save the web map.

The Map Viewer legend below shows the null values displayed with the 'Undefined' label and the non-null values grouped as null values in the Other category.

The null values with a symbology label and the non-null values as null under the Other category

Article ID: 000032462

Software:
  • ArcGIS Online

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options