cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: Comparing multidimensional arrays without nested 'apply to each' actions

 

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
Highlighted
Community Support
Community Support

Re: Comparing multidimensional arrays without nested 'apply to each' actions

 

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
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Kudoed Authors
Users online (8,174)