cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gigmog
New Member

Comparing multidimensional arrays without nested 'apply to each' actions

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]?

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

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,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-bacao-msft
Community Support
Community Support

 

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,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,434)