HOW TO

Separate and reorder text strings within a pop-up using Arcade in ArcGIS Pro

Last Published: July 26, 2023

Summary

In ArcGIS Pro, 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 ArcGIS Pro.

The image below shows a pop-up with the Property Name field and the text string records.

The pop-up of the layer in ArcGIS Pro

Procedure

  1. Start ArcGIS Pro and open the project.
  2. In the Contents pane, right-click the feature class and click Configure Pop-ups to open the Configure Pop-ups pane.
Opening the Configure Pop-ups tool of the feature class from the Contents pane
  1. Click Expressions, and click New.
  2. In the Expression Builder dialog box, configure the following parameters for the Arcade expression.
    1. For Name, rename the new expression.
    2. For Title, specify a title for the new expression.
The Expression Builder dialog box with the parameters to be filled
  1. Specify and insert the appropriate Arcade expression to define the text to display if the condition is met or not in the Expression section.
    1. To define the variable with the function to split the text string and the blank space as a separator, insert:
var <variableName1> = Split($feature.<featureName>, ' ')
  1. To define the variable with the function to count the number of splits for each record, insert:
var <variableName2> = Count(<variableName1>)
  1. To return a blank value when the field value is empty, insert:
If(<variableName2> == 0) {
    return ''
}
  1. To return the same text value when the field is a single word, insert:
If(<variableName2> == 1) {
    return $feature.<featureName>
}
  1. To rearrange the position of the second word to the first position when the field has two words, insert:
If(<variableName2> == 2) {
    return <variableName1>[1] + ' ' + <variableName1>[0]
}
  1. To rearrange the position of the first word to the third position when the field has three words, insert:
If(<variableName2> == 3) {
    return <variableName1>[1] + ' ' + <variableName1>[2] + ' ' + <variableName1>[0]
}
  1. To rearrange the position of the first word to the fourth position when the field has four words, insert:
If(<variableName2> == 4) {
    return <variableName1>[2] + ' ' + <variableName1>[3] + ' ' + <variableName1>[0] + ' ' + <variableName1>[1]
}

The code block below shows the full working expression.

var arrName = Split($feature.PROP_NAME, ' ')
var lenName = Count(arrName)
If(lenName == 0) {
    return ''
}

If(lenName == 1) {
    return $feature.PROP_NAME
}

If(lenName == 2) {
    return arrName[1] + ' ' + arrName[0]
}

If(lenName == 3) {
    return arrName[1] + ' ' + arrName[2] + ' ' + arrName[0]
}

If(lenName == 4) {
    return arrName[2] + ' ' + arrName[3] + ' ' + arrName[0] + ' ' + arrName[1]
}
  1. Click Verify to run a test of the expression. If the expression is valid, click OK.
The Expression Builder dialog box with an example of the Arcade expression
  1. In the Configure Pop-ups pane, click Back The Back icon and click Edit pop-up element.
The location of the Edit pop-element icon in the Configure Pop-ups pane
  1. Ensure the newly created expression check box is checked in the Fields Options pane.
The Fields Options pane

The newly configured pop-up below displays the reordered text strings.

The configured pop-up window displaying the reordered text strings

Article ID: 000030836

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 9x

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