IF Condition with 'AND' and 'OR' Operator in ADF Pipeline Expression Builder

Anubhav Sinha 0 Reputation points
2023-11-07T16:00:42.4533333+00:00

I am making an API call in Azure Function and retrieving values for 7 diff attributes. Out of these 7 attributes 6 of the attributes return Boolean value,whereas one attribute Requested Timestamp will either return Null or some timestamp value.

I am using an IF condition to validate the values of these six attributes which returns value 'TRUE' or 'FALSE' I am using equals ('TRUE',.output) Since the Requested Timestamp attribute might return null or a timestamp value i tried using NULLSAFE operator but its giving me an error. Please find my complete expression below.

@and(and(and(and(and(and( equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['LOCKED?']), equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['DATAHUB READY'])), equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['REQUEST DATA NOW'])), equals('FALSE', activity('SourceSystemFlags').output['SAP Flags']['NDP IMPORTING'])), equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['TRANSACTIONAL DATA IMPORT FLAG'])), equals('FALSE' ,activity('SourceSystemFlags').output['SAP Flags']['SRC SYNC ACTIVE'])), or (activity('SourceSystemFlags').output?,['SAP Flags']['REQUESTED TIMESTAMP']))

I am getting an error saying 'and' is a primitive and doesn't support nested properties. Any kind of help to resolve this problem is highly appreciated.

I even tried using

or (@{activity('SourceSystemFlags').output['SAP Flags']['REQUESTED TIMESTAMP'])} is null)				
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,024 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Amira Bedhiafi 18,661 Reputation points
    2023-11-07T17:04:19.3133333+00:00

    The problem with your code each and function was nested within another, creating a deeply nested structure. This is not only hard to read but also goes against the typical usage pattern of the and function in ADF, which is designed to take multiple boolean expressions as arguments and evaluate them together.

    Here is an improvement, please try and tell us :

    @and(
        equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['LOCKED?']),
        equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['DATAHUB READY']),
        equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['REQUEST DATA NOW']),
        equals('FALSE', activity('SourceSystemFlags').output['SAP Flags']['NDP IMPORTING']),
        equals('TRUE', activity('SourceSystemFlags').output['SAP Flags']['TRANSACTIONAL DATA IMPORT FLAG']),
        equals('FALSE', activity('SourceSystemFlags').output['SAP Flags']['SRC SYNC ACTIVE']),
        or(
            equals(null, activity('SourceSystemFlags').output['SAP Flags']['REQUESTED TIMESTAMP']),
            not(equals(null, activity('SourceSystemFlags').output['SAP Flags']['REQUESTED TIMESTAMP']))
        )
    )
    
    
    1 person found this answer helpful.

  2. AnnuKumari-MSFT 31,896 Reputation points Microsoft Employee
    2023-11-09T06:57:05.8466667+00:00

    Hi Anubhav Sinha ,

    Welcome to Microsoft Q&A platform and thanks for posting your question here.

    As I understand your query , you are facing error while framing expression which includes logical operators like OR and AND. Please let me know if that is not the issue.

    I can see your expression is not correct, kindly compile one condition at a time and then grow the expression. For example, use one 'and' operator with the conditions first to compare the outputs with Boolean value then add another 'and' operator and the corresponding condition and so on. At the end enclose the whole expression with 'or' operator and provide the condition at the end to compare the activity output with null using equals function (is function won't work in ADF).

    Make sure not to have @ in between the expression. Just for sample example , you can refer the below expression:

    User's image

    Hope it helps. Kindly accept the answer by clicking on Accept answer button. Thankyou

    0 comments No comments