How to check multiple conditions in ADF

Viewed 41

enter image description hereI have a scenario where I have to check two conditions and if both are true then execute set of activities in ADF.

I tried if condition activity inside a if condition but ADF is not allowing it.

so basically my design is two lookups to read data and then if condition to check condition 1, if that is true then go inside again two lookups to read data and if condition to check condition 2. But it is not working.

is there any other work around for this?

I tried AND condition inside IF condition activity but it is not working. Please suggest.

1 Answers

Since we cannot use IF within IF activity, we can leverage multiple conditions within an IF activity via expressions which includes if,and ,or etc functions.

The below JSON pipeline is somewhat an example :

{
    "name": "pipeline7",
    "properties": {
        "activities": [
            {
                "name": "If Condition1",
                "type": "IfCondition",
                "dependsOn": [],
                "userProperties": [],
                "typeProperties": {
                    "expression": {
                        "value": "@and(greater(pipeline().parameters.Test2, pipeline().parameters.Test1),greater(pipeline().parameters.Test4, pipeline().parameters.Test3))",
                        "type": "Expression"
                    },
                    "ifFalseActivities": [
                        {
                            "name": "Wait2",
                            "type": "Wait",
                            "dependsOn": [],
                            "userProperties": [],
                            "typeProperties": {
                                "waitTimeInSeconds": 1
                            }
                        }
                    ],
                    "ifTrueActivities": [
                        {
                            "name": "Wait1",
                            "type": "Wait",
                            "dependsOn": [],
                            "userProperties": [],
                            "typeProperties": {
                                "waitTimeInSeconds": 1
                            }
                        }
                    ]
                }
            }
        ],
        "parameters": {
            "Test1": {
                "type": "int",
                "defaultValue": 1
            },
            "Test2": {
                "type": "int",
                "defaultValue": 2
            },
            "Test3": {
                "type": "int",
                "defaultValue": 3
            },
            "Test4": {
                "type": "int",
                "defaultValue": 4
            }
        },
        "annotations": []
    }
}

Your approach is correct in case if you dont want to create another pipeline and use execute activity within the IF activity for another comparision

Related