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 a table view is open in your project, the Calculate Field button opens the Calculate Field geoprocessing tool, so you will always build your expressions as part of a geoprocessing task. Specify the parameters to build an expression using the provided Fields list and functions.
Field Calculator is unavailable
If the Calculate Field command is 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 advanced or simple calculations
The Calculate Field tool allows you to perform advanced calculations using Python code blocks that process data before calculations are made on selected fields.
Simple field calculator expressions are entered into the Expression text box directly. More complex expressions, such as multiline scripts, looping, and branching, are entered in the Code Block box on the Calculate Field tool.
Usage tips
When you're making calculations, keep in mind the following best practices:
- Use double quotation marks when calculating strings.
- 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.