
Announcements
Hey all! I'm looking for a more efficient way to compare two multidimensional arrays in a flow. In my current flow/logicapp I'm doing an 'apply to each' on Array1, nesting an 'apply to each' within on Array2. Below are the two example arrays:
// Array1
[
{
"Color":"Yellow",
"ID":"1"
},
{
"Color":"Blue",
"ID":"2"
},
{
"Color":"Green",
"ID":"3"
}
]
// Array2
[
{
"Category":"Animal",
"MyID":"1"
},
{
"Color":"Automobile",
"MyID":"2"
},
{
"Color":"Building",
"MyID":"3"
}
]
I'm looking for the action or that would match these arrays on ID and MyID, appending the value pairs in each to a final array (Array3). The final array should look like the below.
// Array3
[
{
"Color":"Yellow",
"ID":"1",
"Category":"Animal",
"MyID":"1"
},
{
"Color":"Blue",
"ID":"2",
"Color":"Automobile",
"MyID":"2"
},
{
"Color":"Green",
"ID":"3",
"Color":"Building",
"MyID":"3"
}
]
Though my current method of embedded 'apply to each' works...it is pretty inefficient. I'm thinking there has to be a better way to match up this data with one another. Possibly using union [documentation]?
Hi @gigmog ,
You could refer to the following methods to create Flow.
It seems that there is something wrong with the properties you filled in the array. It seems that color should be Category. If it is color, this is not reasonable.
I changed it to category and then configured the following Flow to integrate the two arrays.
Use the Parse JSON action to parse the properties in the array. Then define a third array variable to integrate the array.
http://johnliu.net/blog/2018/6/a-thesis-on-the-parse-json-action-in-microsoft-flow
Iterate through the first array to determine whether the ID is equal to MyID, and if so, append data to the third array.
You could directly import the .zip file in the attachment to view the configuration of Flow.
Hope this helps.
Best Regards,