cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
christian-aid
Level: Power Up

Merging arrays into one

Hello,

 

I have two parallel Azure AD Get group users actions and I want to merge the result into one so I can then apply a for each to the combined array

 

How can I do that? Thanks

2 REPLIES 2
Super User
Super User

Re: Merging arrays into one

You might have to step through one array using the apply and then use array.add expression to add each item of the second array to the first array

Community Support Team
Community Support Team

Re: Merging arrays into one

Hi @ christian-aid,

 

I have made a test on my side, you could refer to steps below to create the flow:

  1. Add a trigger, here I use the “Manually trigger a flow”.
  2. Add an “Initialize variable”, name the variable as “group users”, the type choose “Array”, leave the “Value” field blank.
  3. Add action “Get group members”, fill in the first Group Id in the input field.
  4. Add an “Apply to each” under the “Get group members”, choose the “Group Members” dynamic content of the “Get group members” in the input field.
  5. Add an “Append to array variable” inside the “Apply to each”, choose the “group users” in the Name field, choose the “Current item” dynamic content of the “Apply to each” in the “Value” field.
  6. Add a parallel branch under the “Initialize variable”, add a “Get group members 2”, “Apply to each 2”, “Append to array variable 2” as step3,4,5.
  7. Add a Compose under the “Apply to each” and “Apply to each 2”, the expression of the Compose as below:

union(variables('group users'),variables('group users'))

Note:This step is to return only one element if there are the same elements in the array.

     8. Add an “Apply to each 3” under the “Compose”, choose the “output ” dynamic content of the Compose in the input field.

     9. You could add a “Compose 2” inside the “Apply to each 3”,choose the “Current item” dynamic content of the “Apply to each 3” in the input field to get every member’s information.

 

 11.png

 

The flow would run successfully as below:

 12.png

 

 

 

Regards,
Alice Zhang

Helpful resources

Announcements
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!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,973)