(ADF V2) How to check if "First" Item() value in "For Each" IS NULL


  • How to check if "First" Item() value in a "For Each" activity IS NULL or some specific value.

    Wednesday, July 11, 2018 8:05 PM

All replies

  • Hi,

    To check whether an item is some specific value, you can use IF Condition activity in ADFv2, reference:

    Foreach activity uses '@item()' to reference each item in collection, I'm afraid we couldn't identify whether an item is the first item only relying on foreach activity.

    This post may give you some help.

    Thursday, July 12, 2018 12:16 AM
  • You could set isSequential to true. Then the loop will be executed sequentially and you will get the first item().

    Do you want to break out for each loop in some cases? If so, I don't think there is a way.

    Thursday, July 12, 2018 2:34 AM
  • Thanks to all that answered.
    Friday, July 13, 2018 2:18 PM
  • There is one but a bit ugly way.  Put an IF statement in the foreach loop. If variable StopLooping = 0 then do activites. Then connect all these activities failed outputs to a SetVariable StopLooping = 1.

    The loop will continue but not execute any more activities or piplines.

    "name": "ContinueOrStopLooping",
    "type": "IfCondition",
    "typeProperties": {
    "expression": {
    "value": "@equals(variables('StopLooping'),'0')",
    "type": "Expression"

    Tuesday, February 26, 2019 6:03 PM