Calculating attributes

You can automate the process of editing feature attributes by using the Field Calculator. The Field Calculator is available from the layer attribute table. In the Field Calculator you enter an expression that calculates values for selected features or for all features in the layer if none are selected. You can calculate values for numeric, text, and date fields.

The simplest kind of expression you can create is a text string. The Field Calculator provides mathematical and logical functions you can use to create more complex expressions. The functions that are available depend on the field type. For example, mathematical functions are available for numeric fields, but not for text fields.

 

Field Calculator expression: STR_NAME="WASHINGTON"

 

This expression will update the STR_NAME attribute for the selected feature. Notice that the text string ("WASHINGTON") is enclosed with double quotes.

 

You can also create expressions based on values in other attribute fields. You can use the mathematical operators to add, subtract, multiply, or divide numeric values in one field by numeric values in another field. For text fields, you can create expressions to concatenate (string together) values from multiple fields.

For example, suppose you have a layer of parcels in which the parcel values are stored in separate pieces—the land value and building value associated with each parcel are stored as separate attributes called LANDVAL and BLDGVAL, respectively. Because taxes are assessed on a parcel's total value, you want the sum of these two attributes to be stored in another attribute called TOTALVAL. With the Field Calculator, you can quickly calculate the TOTALVAL values for all parcels in the layer at once.

 

An expression that add values in two numeric fields to calculate the values for another field

 

The values in the TOTALVAL field will be the sum of the values in the LANDVAL and BLDGVAL fields.

 

You can also create advanced expressions by entering Visual Basic for Application (VBA) statements into the Field Calculator.

To increase editing efficiency for attributes that need to be updated often, you can save expressions and easily reuse them. For example, if the value of the buildings on a parcel increases, you can select the parcel, open the Field Calculator, load the expression for the TOTALVAL field, then voila! quickly update your database.