HOW TO

Assign values in a new field based on values of another field using Arcade in Map Viewer

Last Published: August 18, 2023

Summary

The Find() Arcade expression can be used to create a new field with values assigned based on the values of another field. This expression is useful for classifying the values of a field into groups of values in a new field.

This articles provides the workflow using the Find() Arcade expression in Portal for ArcGIS and ArcGIS Online Map Viewer. In this example, the Arcade expression is used to create a new field called Make_Grouping with values assigned according to the values in the Make field, as seen in pop-up in the image below.

The pop-up of the layer in Portal for ArcGIS Map Viewer

Procedure

  1. Open the map in Map Viewer. Click Layers on the Contents (dark) toolbar, and select the layer with the pop-up for editing.
  2. On the Settings (light) toolbar, click Configure pop-ups > Options > Attribute expressions.
  3. Click + Add expression to open the Arcade expression editor window.
  4. In the editor window, specify a name for the new expression.
  5. In the Expression dialog box, insert the following Arcade expression:
if (Find("<uniquePartOfFieldValue>", $feature.<fieldName>, 0)>-1) {
   return "<newFieldValue>";
} else if (Find("<uniquePartOfFieldValue1>", $feature.<fieldName>, 0)>-1) {
   return "<newFieldValue1>";
}
The code below shows the full working script for assigning eight groups of field values in the Make_Grouping field based on the value of the Make field.
if (Find("Cl", $feature.Make, 0)>-1) {
   return "A";
} else if (Find("Io", $feature.Make, 0)>-1) {
   return "B";
} else if(Find("Ke", $feature.Make, 0)>-1) {
   return "C";
} else if(Find("Lu", $feature.Make, 0)>-1) {
   return "D";
} else if(Find("Mu", $feature.Make, 0)>-1) {
   return "E"
} else if(Find("Or", $feature.Make, 0)>-1) {
   return "F";
} else if(Find("Pa", $feature.Make, 0)>-1) {
   return "G";
} else if(Find("Wa", $feature.Make, 0)>-1) {
   return "H"
}
  1. Click Run to view a preview of the expression result. If the required result is achieved, click Done.
Specifying the Arcade expression in the Portal for ArcGIS Map Viewer editor window
  1. Click the Previous button above the Arcade expression in the Pop-up expressions pane.
The Portal for ArcGIS Map Viewer Pop-up expressions pane with the Previous icon above the newly created expression
  1. Click Fields list to expand the list of fields displayed in the pop-ups, and click Select fields.
  2. Check the expression field under Expressions and click Done.

The map below shows the newly added Make_Grouping field with the assigned values in the pop-up after applying the Arcade expression.

The pop-up displaying the newly added Make_Grouping field in Portal for ArcGIS Map Viewer

Article ID: 000028493

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