azureazure-data-factory

How to Modify a ForEach Object IfCondition to toggle between True and False in Azure Data Factory


My colleague has created a ForEach Object in Azure Data Factory (ADF) with a 'True' or 'False' case, see image. So, as you can see from the image a pipeline executes if 'True', whereas the other pipeline won't execute because it's 'False'. Can someone show me how to modify the 'True' or 'False' cases?

Basically, I would like to swap the cases around.

enter image description here

My expression is as follows:

enter image description here


Solution

  • To modify the "True" or "False" case, we are having 2 workarounds:

    1. By inverting the Expression:

    In Settings tab of the If Condition activity, change the expression from:

    (this is just an example)

    @equals(item().status, 'Yes')
    

    To:

    @not(equals(item().status, 'Yes'))
    

    enter image description here

    This will cause what previously returned true to now return false, and vice versa, effectively swapping the flow.

    1. Manually Swap activities between True/False Branches:

    As you're having 2 branches. One for If condition is True and another for False.

    First, Select the activity (or pipeline execution) under the True branch. Right-click on it and cut.

    enter image description here

    Now, Click into the False branch, Right-click and Paste.

    Do the same in reverse for the activity under the False branch.

    Check for reference - If Condition activity in Azure Data Factory and Synapse Analytics pipelines