You can use field calculations to create an expression to perform simple or complex calculations on your field values in a table. You may want to perform a mathematical calculation on a set of field values for a single record or all records. Performing field calculations is a way to batch update many records in your table at once. Field calculations work on string, number, and date fields, and automatically calculate selected records if the layer or table has a selection set present.
Access the Field Calculator
When an attribute table view is open, you can access a field calculator in the following ways:
- Calculate
—Click the Calculate button
at the top of the table to open the Calculate field toolbar. Calculations run in the toolbar will run as a geoprocessing tool and will be saved in the project’s Geoprocessing history. - Table tab—Click the Calculate Field
or Calculate Field Toolbar buttons
in Tools group on the Table tab at the top of the application.
To calculate a field, you can type or build an expression using the provided Fields and Helpers functions in the expression control.
Field Calculator is unavailable
If the Calculate Field or Calculate field toolbar commands are unavailable, consider the following possibilities:
- A field that is managed by ArcGIS cannot be edited manually. Consequently, you cannot calculate field values for the ObjectID (OID or FID) field or the Shape_Length and Shape_Area fields for a geodatabase feature class.
- The table's data source is read-only, write access can't be established to the folder or geodatabase, or the data source is in a format that can't normally be modified.
- The field belongs to a table that has been joined to your table. You can only calculate values for fields in the origin table.
- The field may be a raster, BLOB, or Global ID type, which cannot be calculated.
Perform field calculations
After you open the table view, you can use the Calculate Field Toolbar or Calculate Field tool to perform field calculations.
Use the Calculate Field Toolbar
Complete the following steps to make calculations using the Calculate Field Toolbar:
- In the table view, click the Calculate button
to open the Calculate Field Toolbar.Alternatively, on the ribbon Table tab, in the Tools group, click Calculate Field Toolbar
. The toolbar can also be found by right-clicking a field header in the table view and selecting Calculate Field Toolbar
. - In the toolbar, for Target Field, choose an existing field to update with a calculation.
- Choose the Language option used by the expression, which can include Python, Arcade, or SQL.
- In the Expression text box, type a valid expression or add fields to the expression using the Add fields to expression menu.
Alternatively, click the Recent Expression button
to insert an expression in the Expression text box. - Optionally, click the Expression Builder button
to open a dialog box with a list of fields and helper functions to build more complex expressions. After you build an expression, click OK to insert it back into the Expression text box. - Optionally, open the Calculate button drop-down menu to turn off Enable Undo.
- Click the Calculate button
to run Calculate Field.Table selections, highlights or filters will be indicated on the Calculate button
. Alternatively, click Calculate All in the drop-down menu to run Calculate Field using all records without losing your selection, highlight or filter. - On the ribbon, click the Edit tab. In the Manage Edits group, click Save to commit the changes.
Use the Calculate Field tool
Complete the following steps to make a calculation using the Calculate Field tool:
- On the Table tab, in the Tools group, click Calculate Field
. - For Field Name (Existing or New), specify the field to be updated with a calculation.
If the specified field name does not exist in the input table, it will be added.
- If a new field name is specified, use the Field Type parameter to specify the type of the new field.
- Choose the Expression Type option used to specify the expression, which can include Python, Arcade, SQL, or VBScript (Deprecated).
- In the Expression parameter, type an expression or use the provided Fields and Helpers options to build an expression.
Perform advanced calculations in Python using the Code Block parameter, which will process the data before calculations are made on selected fields.
- Click OK to run the Calculate Field tool and dismiss the tool dialog box.
Usage tips
When you're making calculations, keep in mind the following best practices:
- Use double quotation marks when calculating strings in Python, and single quotation marks when calculating strings in SQL.
- If you have fields that have been turned off for the layer or table you're working with, they will not be listed. Field visibility is set in the Fields view for your layer.