Field calculations allow the hosted feature layer owner or organization administrator to alter the values of every row for a single field in the attribute table of a layer.
For example, if you have a hosted feature layer that stores information on property sales—including the sale price and tax rate for the property location—you could add a field to the layer to store estimated property taxes. To populate the estimated_property_taxes field, define a calculation expression for the field that takes the values in the sale_price field and multiplies them by the tax_rate values.
Follow these steps to calculate string, numeric, or date field values in a field from the table of a hosted feature layer or hosted table layer in Map Viewer.
Note:
Field calculations cannot be undone. For this reason, a good practice is to add a field, calculate values into it, and confirm the calculation is what you wanted. If it is, you can then calculate the original field to equal the added field. Once you confirm the values are correct in the original field, you can delete the field you added.- Confirm that you are signed in and, if you want to save your changes, that you have privileges to create content.
Note:
You can explore maps, add and configure layers, and more without signing in. To save your work, sign in before creating a map. - In Map Viewer, open the map containing the layer or add the layer directly.
- If you are working with a hosted feature layer, on the Contents (dark) toolbar, click Layers if the Layers pane is not open. If you are working with a hosted table layer, on the Contents (dark) toolbar, click Tables if the Tables pane is not open.
- In the Layers or Tables pane, click Options on the layer and click Show table to open the table.
- In the layer table, click Menu on the column containing the values you want to calculate, and click Calculate field.
The calculate field window appears.
- Choose the language to use for the calculation.
- To use Arcade, click Next, and proceed with the steps below.
- To use SQL, click Calculate field, and follow the steps in Calculate values for a field from the item page.
- Optionally, click Add new to add a filter to calculate values for only a portion of the data, and click Next.
Note:
If you do not add a filter, the calculation is run on all features. If you applied filters to the map or layers in the map before opening the calculate field window, these filters will not be recognized when calculating field values.
- Compose a calculation expression using profile variables and functions. Optionally, do any of the following while composing an Arcade expression:
Note:
For examples of common calculations that can be performed in ArcGIS Online, see Example calculations. Note that the field calculation experience in Map Viewer currently supports Arcade. To calculate fields using Arcade or SQL, see Calculate values for a field from the item page.
- Click Test features filter to add a filter to your test features.
Note:
This option allows you to filter your test features and does not impact what features will be calculated.
- Click Test features to view the table of your test features.
- Click Preview values to preview the calculated values for your test features.
- Turn the Auto preview toggle button off to prevent the calculated values preview from automatically updating while authoring an expression. Turn the Auto preview toggle button on to allow the calculated values preview to update while authoring an expression.
- Click Map , Table , or Map and table to navigate between views.
- Click Test features filter to add a filter to your test features.
- Click Run calculation to run the expression.
The time it takes for the calculation to complete depends on the expression's complexity and the number of features in your layer.