Use the If Condition activity to execute activities based on an expression
The If Condition activity in Data Factory for Microsoft Fabric provides the same functionality that an if statement provides in programming languages. It executes a set of activities when the condition evaluates to true and another set of activities when the condition evaluates to false.
Prerequisites
To get started, you must complete the following prerequisites:
- A tenant account with an active subscription. Create an account for free.
- A workspace is created.
Add an If Condition activity to a pipeline with UI
To use an If Condition activity in a pipeline, complete the following steps:
Creating the activity
Create a new pipeline in your workspace.
Search for If Condition in the pipeline Activities pane, and select it to add it to the pipeline canvas.
Select the new If Condition activity on the canvas if it isn't already selected.
Refer to the General settings guidance to configure the General settings tab.
If Condition settings
Select the Activities tab and provide a dynamic boolean Expression for the If activity. In this simple example, we randomly generate a number between 0 and 1, and return True if the number is greater than or equal to .5, or otherwise False. You can use any of the available functions in the Data Factory expression language or any parameters specified in the pipeline.
After providing the expression for the If Condition, selecting the pencil icon beside each case (True/False) allows you to add as many activities as necessary to be conditionally executed whenever the expression evaluates.
Save and run or schedule the pipeline
Switch to the Home tab at the top of the pipeline editor, and select the save button to save your pipeline. Select Run to run it directly, or Schedule to schedule it. You can also view the run history here or configure other settings.