HOW TO

Replace field values based on conditions in ArcGIS Online

Last Published: July 6, 2023

Summary

In ArcGIS Online, it is possible to replace all the values of a field with a default value. This method is useful when it is necessary to replace certain values of a field for accuracy and better data management.

In this article, fields with a single '0' in the Accidents field (as shown in the image below) are replaced with '1' using an Arcade expression.

Table containing field values to be replaced

Procedure

  1. In ArcGIS Online, on the Content tab, click the desired hosted feature layer. On the item details page, click the Data tab.
  2. Click the field header and select Calculate. In this example, Accidents is selected.
  3. In the Calculate Field dialog box, click Arcade.
Calculate Field dialog box language selection page
  1. In the Arcade Calculator dialog box, specify the Expression field as follows:
if ($feature.<field_name> == '<initial_value>') {
  Replace($feature.<field_name>, '<initial_value>', '<new_value'>)
} else {
    return($feature.field_name>)
}
  1. Replace <field_name> with the name of the field that must be replaced with a specific value. In this example, it is 'Accidents'.
  2. Replace <initial_value> with the field value that must be replaced. In this example, it is ‘0’.
  3. Replace <new_value> with the field value that must be populated to replace the existing value. In this example, it is ‘1’.
  1. Click Test to verify the expression, and click OK to apply the query.
Expression configured in the expression box

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

Field with original values replaced and populated with new values

Article ID: 000030689

Software:
  • ArcGIS Online

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options