cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Combine arrays without conditions

To make a long story short, I have two arrays in Flow:

 

Array 1:

[
{
"id": 68,
"count": 5
},
{
"id": 69,
"count": 4
},
{
"id": 71,
"count": 2
},
{
"id": 78,
"count": 2
},
{
"id": 82,
"count": 17
}
]

 

Array 2:

[
"Project1",
"Project2",
"Project3",
"Project4",
"Project5"
]

 

where the ids from Array 1 match in the same order of the Projects in Array 2.

 

Is there anyway to combine/merge these two arrays to get an array that looks like this?


[
{
"id": 68,
"Name": "Project1",
"count": 5
},
{
"id": 69,
"Name": "Project2",
"count": 4
},
{
"id": 71,
"Name": "Project3",
"count": 2
},
{
"id": 78,
"Name": "Project4",
"count": 2
},
{
"id": 82,
"Name": "Project5",
"count": 17
}
]

 

I spent all day trying to get this right and was defeated.

 

Thanks for the help!

ltd224

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Re: Combine arrays without conditions

Hi!

This approach is slow in terms of performance but works like a charm. Array1 and Array2 stored in the variables with the same name.

Now, the expressions used inside 'Append to array' are:

item()?['id']
variables('Array2')[variables('Index')]
item()?['count']

 

Flow_MergeArrays.png

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

2 REPLIES 2
Highlighted
Dual Super User III
Dual Super User III

Re: Combine arrays without conditions

Hi!

This approach is slow in terms of performance but works like a charm. Array1 and Array2 stored in the variables with the same name.

Now, the expressions used inside 'Append to array' are:

item()?['id']
variables('Array2')[variables('Index')]
item()?['count']

 

Flow_MergeArrays.png

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted
Frequent Visitor

Re: Combine arrays without conditions

Thank you @efialttes !

 

This works great!

 

Now I'm going to go nurse by flat forehead...

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (4,756)