If Data Exists tool
The following example uses the If Data Exists tool to check if the input features from a model parameter exist. The If Data Exists tool has two Boolean outputs: True and False. If the input exists, the True output variable and the precondition are set to true, allowing the Calculate Field tool to run. If the False output variable is true (meaning the data does not exist), the model makes a copy of another dataset and runs the Calculate Field tool using this alternate dataset as input.
If Field Exists tool
The following example uses the If Field Exists tool to check if fields of a given name already exist in a dataset. The If Field Exists tool has two Boolean outputs: True and False. If the field does not exist in the input dataset, the False output variable and precondition are set to true, allowing the Add Field tool to run. If the True output variable is true (meaning the field does exist), the model ends as no tools are connected to the True branch.
If Selection Exists tool
The following example uses the If Selection Exists tool to check if the input has any selected features and if so, the number of selected features. If Selection Exists is used after first running Selection Layer By Attribute. The If Selection Exists tool has two Boolean outputs: True and False. If the input has any selected features, the True output variable and the precondition are set to true, allowing the Summary Statistic tool to run. If the False output variable is true (meaning no features are selected), the model ends as no tools are connected to the False branch.
If Coordinate System Is tool
The following example uses the If Coordinate System Is tool in ModelBuilder to check if a dataset has a certain coordinate system. The If Coordinate System Is tool has two Boolean outputs: True and False. This model iterates over feature classes in a geodatabase and checks if each feature class has a particular projected coordinate system. If each feature class does not have a specified coordinate system, the False output variable and the precondition are set to true, allowing the Project tool to run. If the True output variable is true (meaning the input dataset has the specified coordinate system), the model ends because no tools are connected to the True branch.
If Data Type Is tool
The following example uses the If Data Type Is tool to check the data type of the input dataset. The If Data Type Is tool has two Boolean outputs: True and False. This model checks if the input data model parameter is a shapefile or feature class and processes the data accordingly. If the input data is a shapefile, the True output variable and the precondition are set to true, allowing the bottom branch of multiple Add Field and Calculate Field tools to run. If the False output variable is true (meaning the input data is not a shapefile), the model runs the top branch.
If Expression Is tool
Many business entities have mandated wearing masks to protect against COVID-19. The following example uses the If Expression Is tool to find business entities with or without mandated mask policy. This model has an input parameter named Mask and based on its value, the model selects specific data for analysis. The If Expression Is tool has two Boolean outputs: True and False. The Expression parameter uses inline variable substitution and checks the value of Mask. If the Mask parameter is set to "Yes", the True output variable and the precondition are set to true, allowing the connected Select Layer By Attribute tool to select only those business entities that have mandated masks. If the value of the Mask parameter is set to any other value, the False output variable and precondition are set to false, and the connected Select Layer By Attribute tool is set to select business entities with no mask policy.
If Feature Type Is tool
The following example uses the If Feature Type Is tool to check if a specific dataset is a point feature class. The Adds Locations tool only accepts points as input, so if points are not provided as input to the model, the input features can first be converted to points. The If Feature Type Is tool has two Boolean outputs: True and False. If the input features are polygons or lines, the True output variable and the precondition are set to true, allowing the Feature to Point tool to run and convert the features to points. If the False output variable is true (meaning the input features are not polygons or lines), the model uses the input features as-is without first converting them to points.
This model also uses the Merge Branch tool to merge both the True and False branches so that the same chain of tools can be run on either branch.
If Field Value Is tool
The following example uses the If Field Value Is tool to check if the input data has a particular value in an attribute field. The If Field Value Is tool has two Boolean outputs: True and False. If the specified field has the test value, the True output variable and the precondition are set to true, allowing the Apply Symbology from Layer tool to run. If the test value does not exist in the attribute field, the False output variable is true and the Add Join tool executes before applying the symbology.
If Row Count Is tool
The following example uses the If Row Count Is tool to check the number of records in the input dataset. The If Row Count Is tool has two Boolean outputs: True and False. If the input dataset has more than one feature, the True output variable and the precondition are set to true, allowing the Dissolve tool to run. If the input dataset does not have more than one feature, the False output variable is true and the tools in the bottom branch are run.
If Spatial Relationship Is tool
The following example uses the If Spatial Relationship Is tool in ModelBuilder to check if a layer has features with a spatial relationship with another layer's features. The If Spatial Relationship Is logical tool has two Boolean outputs: True and False. In this example, if any of the crime data intersects the school district, the True output variable and the precondition are set to true, allowing the Make Feature Layer and Select Layer by Location tools to run. If the False output variable is true (meaning no input features have the specified spatial relationship with the selecting features), the model ends as no tools are connected to the False branch.
If Value Is tool
The following example uses the If Value Is tool to find affordable housing from the current real estate listings. The model has three input parameters that allow potential buyers to provide values for Type of Property, Maximum Price, and a Boolean choice of Are you flexible with the price?. The If Value Is logical tool then checks if the potential buyer is flexible with the values chosen. The If Value Is tool has two Boolean outputs: True and False. If the buyer is flexible, the True variable and the precondition are set to true, allowing the Select Layer By Attribute to add another $100,000 buffer to the specified price before selecting all the homes from the available home listings. If the buyer is not flexible, the False parameter and the precondition are set to true, allowing the second Select Layer By Attribute tool to select only those houses that are within the price range specified by the buyer.