Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Need to remove duplicates from output of applytoeach list

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Capture.PNG

in the above screen shot in the Compose 2 action named region - I am getting list of regions but contains duplicates.

I have to remove duplicates.

In one of the post it was said to remove duplicates use union on some variable.

I tried to do but . I tried adding Append to array variable but when I click on Name drop down list I don't see any.

what name I have to choose?

where should I initialize the variable.

It seems I can't initialize in ApplyToEach, I can only use append array variable.

Any help ?

  • Verified answer
    ShivaPatpi Profile Picture
    Microsoft Employee on at
    Re: Need to remove duplicates from output of applytoeach list

    i was able to figure it out. I was self referencing the same variable twice in the for each loop which was going in a cycle.

     

  • ShivaPatpi Profile Picture
    Microsoft Employee on at
    Re: Need to remove duplicates from output of applytoeach list

     Capture.PNG

    Also i am getting above error when i try to add Append to array variable

  • ShivaPatpi Profile Picture
    Microsoft Employee on at
    Re: Need to remove duplicates from output of applytoeach list

     Capture.PNG

    What should be the Join With ???

  • ShivaPatpi Profile Picture
    Microsoft Employee on at
    Re: Need to remove duplicates from output of applytoeach list

    @v-bacao-msft  , what will be the Join with value ?

  • v-bacao-msft Profile Picture
    on at
    Re: Need to remove duplicates from output of applytoeach list

     

    Hi @ShivaPatpi ,

     

    You could first append all regions to an array variable and then use the union() function to remove duplicate elements from the array.

    Finally, you could use the Join action to extract regions.

    Image reference:

    80.PNG

     

    Best Regards,

  • RobElliott Profile Picture
    10,118 Super User 2025 Season 1 on at
    Re: Need to remove duplicates from output of applytoeach list

    @ShivaPatpi or you can just use a Union expression which strips out duplicates from the 2 variables:

    union(variables('varTown'),variables('varTownCounty'))

    1-Append.png

    Rob
    Los Gallardos
    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

  • DeepakS Profile Picture
    2,301 Most Valuable Professional on at
    Re: Need to remove duplicates from output of applytoeach list

    Hi @ShivaPatpi 

     

    Here is an example Power Automate to remove duplicates form an Array:

    Duplicate.png

     

    ——————————————————
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow