Calculator expression

Use the Expression control to build expressions that calculate field values and configure labels, pop-ups, charts, and symbology. The Expression control is found in several locations in ArcGIS Pro, including the Calculate Field tool’s Expression parameter, label expressions, attribute rules, symbology, charts, and more.

Expression parameter

The Calculate Field tool's Expression parameter

The Expression control supports the following expression types: Arcade, Python, VBScript, SQL, and JScript, although not every instance of the control supports each type.

The Expression control includes the following elements to build an expression:

  • Fields—Double-click a field name in the list of fields from a layer or dataset to add the field name to the expression. The field name will include delimiters depending on the expression type.
  • Functions or Helpers—Double-click a function from the list to add the function code to the expression and code block. Not all expression languages or types support the same functions. Each function uses syntax that is appropriate for the expression type.
    Note:

    Fields that have visibility turned off will not be shown.

  • Insert Values—Inserts field values from a selected field in the Fields list. If the selected field has a domain, the domain values are separately listed in the Insert Values drop-down menu.
  • Clear button Clear—Clears the expression value.
  • Verify button Verify—Checks the expression for syntax errors.
  • Import button Import—Opens a browse dialog box to select an existing calculation file (.cal) and loads an expression and code block.
  • Export button Export—Writes the expression value and code block to a calculation file (.cal).

Calculate Field

Use the Calculate Field tool's Expression parameter to build expressions to calculate a dataset’s field values. An expression can be a single field value, text (always enclosed in quotations, for example, "Text"), or a number. You can also build an expression using multiple fields, operators, and functions.

In addition to the elements described above, the Calculate Field tool’s Expression parameter also includes the following elements:

  • Operators—Buttons that you can click to add basic mathematical operators to an expression, including multiply, divide, plus, and minus.
  • Code BlockPython and VBScript expressions support more complex expressions using one or many functions in a code block. The code block can include multiline code, looping, and branching. The code block must relate back to the expression, and the result of the code block must be passed to the expression.

    Learn more about using the code block with Calculate Field

  • Recent Recent—Select an expression from the list of recent expressions. The tool saves and stores recent expressions when you run the tool. It does not save expressions that result in a syntax or invalid expression error. The tool saves recent expressions in your user profile, making them available between multiple projects.


In this topic
  1. Calculate Field