HOW TO

Display concatenating labels based on field values using Arcade expression in ArcGIS Online and Portal for ArcGIS Map Viewer

Last Published: February 28, 2023

Summary

In ArcGIS Online and Portal for ArcGIS Map Viewer, when the same field value is present in multiple fields, a conditional Arcade expression can be used to display concatenating labels. In this article, the feature layer contains two fields named ‘Married’ and ‘Employed’. Using an Arcade expression, labels are created by concatenating the field names when the feature contains the ‘Yes’ field value for both fields.

The image below displays a table with the two fields and field values.

Attribute table displaying fields and the field values.

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 on the Enable labels option.
  3. In the Label features pane, click Add label class. Under Label field, click Use expression Icon to open expression editor window..
  4. In the editor window, configure the expression below.
var output = '';
if ($feature['<field_name1>'] == '<field_value>'){
     output = '<output1> ';
}
if ($feature['<field_name2>'] == '<field_value>'){
     output += '<output2>'
}
else{ 
     output = '<output3>'
}
return Trim(output);
  1. Replace <field_name1> and <field_name2> with the name of the fields which displays the concatenating labels if the conditions are met. In this example, the Married field is used for <field_name1> and the Employed field is used for <field_name2>.
  2. Replace <field_value> with the desired field value for the multiple fields in an attribute table. In this example, ‘Yes’ is the field value used.
Note:
If numeric or date field values are used, remove the single quotes (' ') on <field_value>.
  1. Replace <output1> and <output2> with the name of the fields to concatenate as labels. In this example, ‘Married’ and ‘Employed’ are used in the label. Specify a space after the first statement to allow the next statement to concatenate clearly for the labels.
Note:
If a different concatenating label is desired, users can configure the output statements to something other than the names of fields.
  1. Replace <output3> with the desired label to be displayed when one of the field values does not meet the condition. In this example, 'Irrelevant' is used.
  1. Click Done.
Label expression editor window.

The image below displays the concatenating labels on the web map.

Web map displaying concatenating labels.

Article ID: 000029386

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