kriSHna
Performing Array and Object comparison in Power Automate
#array #powerautomate #msflow #compare
In Power Automate we might always need to make some comparison in arrays be it finding the elements that are similar in the array or eliminating the duplicate items from the array. Instead of using the Apply to each step and increasing the processing time we can use expressions to complete the same.
In this article, we will be looking at intersection and union expressions of Power automate and how we can incorporate those to reduce the processing time.
Intersection in Power Automate
There is a workflow function called intersection in Power Automate, this helps us in extracting the elements that are similar in the arrays.
syntax : intersection([<collection1>], [<collection2>], ...)
Let's consider we have Array1 with data [1,2,3,4,5] and Array2 with data [2,3,6,7,5] when we do a comparison between these two arrays it will result in [2,3,5] as only those elements are similar in both the arrays.
intersection(Array1,Array2)
We can also perform a similar comparison on the objects, considering we have two objects Object1 with data as { "Name": "John", "Age": 25, "Place": "ABC" } and Object2 with data as { "Name": "Spark", "Age": 25, "Place": "ABC" }
the result would be { "Age": 25, "Place": "ABC" }
for more information related to the intersection workflow function, please check here
Union in Power Automate
We also have another workflow function union in power automate, this will help us in eliminating the duplicates from the arrays. Instead of using apply to each and performing a lengthy comparison process, we can directly use the union to achieve the same
Syntax : union('<collection1>', '<collection2>', ...)
Consider we have two arrays Array1 and Array2
Array1 = [1,2,3]
Array2 = [1, 2, 10, 101]
union(Array1,Array2) = [1,2,3,10,101]
For more information related to the union workflow function, please check here
Hope this article is helpful, for any queries for information please reach out to us via the Contact Us section.