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.