If condition with multiple For each in azure data factory

K, Kumaresan 21 Reputation points

I'm trying to compare two arrays from different for each activity and do a if conditional activity. But I'm unable to use two for each in a single if conditional activity. Kindly assist

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,751 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,036 Reputation points

    Hello @K, Kumaresan and welcome to Microsoft Q&A.

    Thank you for your excellent question. There are a few ways to approach this. However before we can get into details, it is necessary to know whether the two arrays are always the same length. Arrays of differing length require special approaches.

    One tool we will use is range(start,length). This we will use to create an array of numbers to serve as indexes. ([0,1,2,3,...,N-1])

    We can use this array of indexes to get elements in the arrays by index.

    Instead of trying to nest a conditional activity inside a forEach, I have other suggestions. Use the array of indexes inside a filter activity. Like,

    greater(variables('arrayX')[item()], variables('arrayY')[item()])  

    This would output the indexes of elements where arrayX > arrayY.

    After that, you can use a forEach activity on these output to do whatever.

    0 comments No comments