Skip To Content

If-then-else branching and logical tools

If-then-else logic is a powerful concept for performing different actions based on different conditions. If-then-else logic can be explained as such:

  • IF some condition is true
    • THEN perform an action
  • ELSE the condition is false
    • perform a different action

In ModelBuilder, if-then-else logic can be added using the set of built-in Logical tools or with custom Python functions or script tools.

Logical tools

Logical tools are a category of ModelBuilder utilities that help you control the flow of processes in a model and enable if-then-else branching logic.


If Data Exists

Evaluates if the specified data exists.

If Field Exists

Evaluates if the input data has the specified fields.

If Selection Exists

Evaluates if the input data has a selection and if a certain number of records are selected.

If Coordinate System Is

Evaluates if the input data has the specified coordinate system.

If Data Type Is

Evaluates if the input data matches the specified data type.

If Feature Type Is

Evaluates if a feature class is of the specified feature type.

If Field Value Is

Evaluates if the values in an attribute field match a specified value, expression, or second field.

If Row Count Is

Evaluates if the row count of the input data matches a specified value.

If Spatial Relationship Is

Evaluates whether the inputs have a specified spatial relationship.

If Value Is

Evaluates an input value against a single value, a list of values, or a range of values using a defined comparison operator.

Merge Branch

The Merge Branch tool merges two or more logical branches into a single output.


Stops iteration if all inputs values meet the specified condition of True or False. It is functionally similar to the While iterator but is useful to stop a model if there is one While iterator in a model and no additional iterators can be added.

Learn more about using the Logical tools in ModelBuilder


In addition to the built-in Logical tools in ModelBuilder, you can write your own functions and tools to perform if-then-else branching using custom Python functions with the Calculate Value tool. These functions can test conditions using a variety of arcpy and other Python capabilities, and output Boolean true and false variables. Similarly, you can write a Python script that tests conditions and outputs Boolean true and false variables, make the script into a geoprocessing script tool, and add the script tool to your model.

In this topic
  1. Logical tools
  2. Python