Skip to main content

Notifications

Community site session details

Community site session details

Session Id : bmPvs9Q2/pVzUomLJ6d6nY
Power Automate - Building Flows
Answered

Merge 2 array bodies into single array using append to array variable in power automate

Like (0) ShareShare
ReportReport
Posted on 9 Mar 2023 01:44:43 by 75

Hello, 

 

I have 2 arrays resulting from 2 different 'Select' operation as below , I need to combine the output into single array for using it in looping later for each unique value in "Apply to each" step. 

 

I tried using "append to array variable ", but it does not merge the elements inside array.

Can you please let me know what I am missing here ? 

 

Sivaperumal31_1-1678326125983.png

 

Sivaperumal31_2-1678326170526.png

 

Sivaperumal31_3-1678326190105.png

 

Thank you 

 

  • Sivaperumal31 Profile Picture
    75 on 10 Mar 2023 at 00:51:56
    Re: Merge 2 array bodies into single array using append to array variable in power automate

    Thank you @grantjenkins .

  • Verified answer
    grantjenkins Profile Picture
    11,057 Super User 2025 Season 1 on 09 Mar 2023 at 12:55:52
    Re: Merge 2 array bodies into single array using append to array variable in power automate

    @Sivaperumal31 You can use the union expression to combine any number of arrays. Below is an example of how it works.

     

    //Will combine all arrays into a single array and remove any duplicate values
    
    union(array1, array2, array3, array...)

     

    See example below where I have three Selects similar to yours where we then use a union expression to combine them and remove any duplicate values.

    grantjenkins_5-1678366182527.png

     

    My three Selects have the following output. Note that "MY" Is listed twice so one of them will be removed when we apply the union expression.

    grantjenkins_6-1678366228108.png

    grantjenkins_2-1678366023775.png

    grantjenkins_3-1678366044845.png

     

    Compose uses the following expression to combine (union) the Selects and remove duplicate values.

    union(body('Select_1'), body('Select_2'), body('Select_3'))

    grantjenkins_7-1678366324754.png

     

    This would give the output below.

    grantjenkins_9-1678366403694.png

     

    Apply to each uses the output from Compose so it iterates over each of the items in the array.

    grantjenkins_8-1678366382912.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • Sivaperumal31 Profile Picture
    75 on 09 Mar 2023 at 05:30:18
    Re: Merge 2 array bodies into single array using append to array variable in power automate

    Thank you @v-liwei-msft , It worked , I missed "Apply to each " before . 

    I assume I have to use another "Apply for each "  if I have to combine 3rd Array ? 

    Guess no other way to combine multiple array(3 or more ) other than using "apply to each" for every array to be appended .

  • Verified answer
    v-liwei-msft Profile Picture
    on 09 Mar 2023 at 03:27:22
    Re: Merge 2 array bodies into single array using append to array variable in power automate

    Hi @Sivaperumal31 

     

    I have made a test for your reference:

    1.

    vliweimsft_0-1678332328690.png

    2.

    vliweimsft_1-1678332403429.png

    3.

    vliweimsft_2-1678332433570.png

     

    Best Regards,

    Levi

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,342 Most Valuable Professional

Leaderboard