cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ltd224
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
efialttes
Super User III
Super User III

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
efialttes
Super User III
Super User III

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

ltd224
Frequent Visitor

Thank you @efialttes !

 

This works great!

 

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

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,463)