web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : dLvCy7edXvnIPT9BEvP3JD
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,059 Moderator 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

Announcing our 2025 Season 2 Super Users!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete