HOW TO

Replace field values based on conditions in ArcGIS Pro

Last Published: May 26, 2024

Summary

In ArcGIS Pro, it is possible to replace all the values of a field with a default value. However, it is sometimes necessary to replace only certain values of the field for enhanced data accuracy and nuanced spatial analysis.

In this article, fields with a single '0' in the Distance field are replaced with '1' using an Arcade expression. The image below displays the attribute table with the field values to be replaced.

Attribute table displaying field values that needs to be replaced.png

Procedure

  1. Open the ArcGIS Pro project.
  2. In the Contents pane, right-click the feature layer and click Attribute Table.
  3. In the attribute table, right-click the field name, and select Calculate Field. In this example, the Distance field is selected.
  4. In the Calculate Field window, specify the following parameters:
    1. For Input Table, ensure the layer selected in Step 2 is prefilled. In this example, the input table is test.
    2. For Field Name, ensure the field selected in Step 3 is prefilled. In this example, the field name is Distance.
    3. For Expression Type, select Arcade.
    4. For Expression, in the expression box, specify the expression provided below. Replace <field_name> with the name of the field that must be replaced with a specific value. Then, replace <initial_value> with the field value that must be replaced and <new_value> with the replacement field value.
if ($feature.<field_name> == '<initial_value>') {
  Replace($feature.<field_name>, '<initial_value>', '<new_value>')
} else {
   return($feature.<field_name>)
}
Note:
If numeric or date field values are used, remove the single quotes (' ') on <initial_value> and <new_value>.
  1. Click the Verify icon to validate the expression.
  2. Click OK to run the script.
Calculate field window configurations.png

The image below displays the new field values in the Distance field.

Attribute table containing new field values.png

Article ID: 000031567

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

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