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 available in the following locations in ArcGIS Pro:

Expression parameter in the Calculate Field tool

The Expression control supports the following expression types: ArcGIS 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.
    Note:

    Fields that have visibility turned off will not be shown.

  • 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.
  • Insert Values—Insert field values from a selected field in the Fields list. If the selected field has a domain, the domain values are listed separately in the Insert Values drop-down menu.
  • Clear button Clear—Clear the expression value.
  • Verify button Verify—Check the expression for syntax errors.
  • Import button Import—Open a browse dialog box to select an existing calculation file (.cal) and load an expression and code block.
  • Export button Export—Write the expression value and code block to a calculation file (.cal).

Calculate Field

Use the Calculate Field tool Expression parameter or the Calculate Field toolbar Expression Builder dialog box to build expressions to calculate field values. An expression can be a single field, text (always enclosed in quotation marks, 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 Expression control in the field calculators also include 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 for multiple projects.


In this topic
  1. Calculate Field