HOW TO

Apply commas between two or more values in a list with Arcade in ArcGIS Dashboards

Last Published: August 9, 2023

Summary

ArcGIS Arcade expressions can be used in ArcGIS Dashboards to customize how the data points appear in the list element.

This article provides the steps to apply commas between two referenced field values, CITY and DISTRICT, with Arcade in ArcGIS Dashboards. 

Shown below is the list element without the Arcade expression.

An example of the List element without the Arcade expression enabled

Procedure

  1. Open the ArcGIS Dashboards item. Click View on the dashboard toolbar and click Options The horizontal ellipsis icon, found next to the element. Click Configure.
The dashboard toolbar with the View tab
  1. Click List to open the List options menu, and click Enable.
The advanced formatting of the List element in ArcGIS Dashboards
  1. Specify the following Arcade expression in the Expression window.
// Edit the desired variable name and required field name accordingly
var <variableName1> = IIF(IsEmpty($datapoint.<fieldName1>), '', $datapoint.<fieldName1>)
var <variableName2> = IIF(IsEmpty($datapoint.<fieldName2>), '', $datapoint.<fieldName2>)
var <variableName3> = IIF((IsEmpty($datapoint.<fieldName1>)) ||(IsEmpty($datapoint.<fieldName2>)), '', ',')
var <variableName4> = <variableName1> + <variableName3> + ' ' + <variableName2>

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
  attributes: {
   <variableName4>: <variableName4>
    }
}

The code block below demonstrates the full working expression.

// Edit the desired variable name and required field name accordingly
var city = IIF(IsEmpty($datapoint.CITY), '', $datapoint.CITY)
var district = IIF(IsEmpty($datapoint.DISTRICT), '', $datapoint.DISTRICT)
var comma = IIF((IsEmpty($datapoint.CITY)) ||(IsEmpty($datapoint.DISTRICT)), '', ',')
var location = city + comma + ' ' + district

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
  attributes: {
   location: location
    }
}
The Arcade expression in the ArcGIS Dashboards Expression window
  1. Scroll down to the Line item template editor dialog box and type the attribute expression syntax into the desired position. In this example, the {expression/location} syntax is used.
  2. Click Done.
The Line item template to configure the List element in ArcGIS Dashboards

Shown below is the list element with the Arcade expression.

The List element with the Arcade expression enabled

Article ID: 000030956

Software:
  • ArcGIS Online
  • ArcGIS Dashboards

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