HOW TO
In ArcGIS Online and Portal for ArcGIS Map Viewer, Arcade expressions with multiple statements can be used to split and reposition text strings of a field within a pop-up. The repositioned text strings can be used for data management or search results optimization. This article provides an example and instructions using Arcade expressions to split and rearrange text strings within a pop-up for Map Viewer.
The image below shows a Map Viewer pop-up with the Forest_Name field and the text string records.
var <variableName1> = Split($feature.<featureName>, ' ')
var <variableName2> = Count(<variableName1>)
if (<variableName2> == 0) { return '' }
if (<variableName2> == 1) { return $feature.<featureName> }
if (<variableName2> == 2) { return <variableName1>[1] + ' ' + <variableName1>[0] }
if (<variableName2> == 3) { return <variableName1>[1] + ' ' + <variableName1>[2] + ' ' + <variableName1>[0] }
The code block below is an example of the full working expression.
var arrName = Split($feature.Forest_Name, ' ') var lenName = Count(arrName) if (lenName == 0) { return '' } if (lenName == 1) { return $feature.Forest_Name } if (lenName == 2) { return arrName[1] + ' ' + arrName[0] } if (lenName == 3) { return arrName[1] + ' ' + arrName[2] + ' ' + arrName[0] }
The image below shows the newly added Sorted Forest Names field with the rearranged values in the pop-up after using the Arcade expression.
Get help from ArcGIS experts
Download the Esri Support App