If Expression Is (ModelBuilder)

Summary

Evaluates whether a given Python expression is True or False.

Learn how If Expression Is works in ModelBuilder

Usage

  • This tool is only available from the ModelBuilder ribbon for use in models. The tool is not available from the Geoprocessing pane or from Python.

  • The tool has two Boolean outputs, True and False. Based on the condition being evaluated, one of the two Boolean outputs is true and the other is false after the tool runs. These Boolean outputs must be set as a precondition to the downstream tools for those to execute if either of the preconditions is true.

  • The Expression parameter only supports Python expressions. Other scripting languages are not supported.

  • Use the Expression parameter for short one-line expressions. Use the Code Block parameter for more complicated expressions, such as multiline calculations or logical operations. The Code Block parameter cannot be used on its own; it must be used in conjunction with the Expression parameter.

  • Variables created in ModelBuilder can be used by this tool but cannot be connected directly to the Expression parameter. To use a variable in the expression, enclose the variable name in percent signs.

  • You cannot access model variables in the Code Block parameter. These variables must be passed on to the code block from the expression. To do this, create a function definition in the Code Block parameter and reference the Expression parameter value.

  • In Python, proper indentation is part of the syntax. The indentation level (two spaces or four spaces) does not matter as long as it is consistent throughout the code block.

Parameters

LabelExplanationData Type
Expression

The Python expression to be evaluated.

SQL Expression
Code Block

A Python code block. The code in the code block must be referenced in the Expression parameter.

String

Derived Output

LabelExplanationData Type
True

If the specified criteria evaluates to True, this parameter will be set to True.

Boolean
False

If the specified criteria evaluates to False, this parameter will be set to True.

Boolean

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics