HOW TO

Label a feature layer based on field value differences in Map Viewer

Last Published: December 22, 2023

Summary

In Map Viewer, it is possible to label numeric data in a feature layer by calculating the difference between multiple field values and comparing it with a fixed value using an Arcade expression. This is useful for dynamically highlighting variations within the geographic dataset and quickly identifying patterns, trends, or anomalies.

In this article, the feature layer contains two fields named Income and Expense. Using an Arcade expression, labels are created by calculating the difference between the two field values, and the difference is compared to a fixed value of 5000.

Procedure

  1. Open the web map in Map Viewer.
  2. On the Settings (light) toolbar, click Labels Labels icon. Ensure labels are enabled by toggling Enable labels on.
  3. In the Label features pane, click Add label class. Under Label field, click Use expression Use expression icon
  4. In the editor window, configure the expression below.
var <variable1> = $feature.<field_name1>;
var <variable2> = $feature.<field_name2>;
var <variable3> = <value>;                                                                               

if (<variable1> - <variable2> > <variable3>) {
    return "<output1>";
} else if (<variable1> - <variable2> < <variable3>) {
    return "<output2>";
} else {
    return "<output3>";
}
  1. Replace <variable1>, <variable2>, and <variable3>with the desired variable names. In this example, income, expense, and budget are used.
  2. Replace <field_name1> and <field_name2> with the names of the fields containing the field values. In this example, Income and Expense are used.
  3. Replace <value> with a value to be compared with the difference between the two field values. In this example, it is 5,000.
  4. Replace <output1>, <output2>, and <output3> with the statements to be displayed as labels. In this example, Above Budget, Below Budget, and On Budget are the statements used.
  1. Click Done.
Arcade expression configuration in editor window

The image below displays the labels with the field value differences on the web map.

Web map displaying comparing field values labels

Article ID:000031591

Software:
  • ArcGIS Online

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