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.
Procedure
- In ArcGIS Online, on the Content tab, click the desired hosted feature layer. On the item details page, click the Data tab.
- Click the field header and select Calculate. In this example, Accidents is selected.
- In the Calculate Field dialog box, click Arcade.
- 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>)
}
- Replace <field_name> with the name of the field that must be replaced with a specific value. In this example, it is 'Accidents'.
- Replace <initial_value> with the field value that must be replaced. In this example, it is ‘0’.
- Replace <new_value> with the field value that must be populated to replace the existing value. In this example, it is ‘1’.
- Click Test to verify the expression, and click OK to apply the query.
The image below displays the new field values in the Accidents field.