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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Removing Array Duplicates
Power Automate
Answered

Removing Array Duplicates

(0) ShareShare
ReportReport
Posted on by

I have a Flow that sends an Email to people in a contact list, but I sometimes get duplicate values in my array.

 

I dont want to send multiple messages to the same Email, so i need to remove the duplicated values.

 

Any idea how can i do that? 

Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at

    Hi!

    I would suggest to use union() WDL function

    Give me some minutes to write a clear example

  • Verified answer
    efialttes Profile Picture
    14,756 on at

    @Anonymous 

    Let's assume you have your array stored in a variable called 'myArray'. In order to remove duplicates all you need to do is to create a 'Compose' action block, and assign it the following WDL expression

     

    union(variables('myArray'),variables('myArray'))

     

    You can also assign the expression to a new variable, if you prefer it instead of the Compose approach

    Suerte!

  • Verified answer
    yashkamdar Profile Picture
    1,044 on at

    Hello Team,

     

    This is extremely easy to implement, let me guide you.

     

    First see my outputs and final results-

     

    I had an array that had values 1,2,2,3,2 and needed to remove duplicates.


    I used the Union() expression and got the final result 1,2,3.

     

    yashkamdar_0-1600431298250.png

     

    How to do this, first load your array outputs in COMPOSE. My Array outputs are currently residing in array variable called ARRAY

     

    yashkamdar_1-1600431377021.png

     

     

    Then Create another COMPOSE and use the following expression -

     

     

    union(outputs('Compose'),variables('Array')) 

     

     

    Here COMPOSE is the action where the Array was loaded and Array is the name of the Array variable. Please refer the 1st compose action we create you will understand it.

     

    This is all you need to do.

     

    Once this is done, create another COMPOSE and load the outputs of Compose created earlier (the one where we put the expression) to get unique values returned.

     

     

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

     

  • Community Power Platform Member Profile Picture
    on at

    Thank you very much for the detailed explanation.

     

    This worked as expected.

  • Community Power Platform Member Profile Picture
    on at

    Thabnk you very much, this was very usefull!

  • ManiLive Profile Picture
    41 on at

    A faster way to remove duplicates is to union the input array with an empty array.  This saves a lot of time with larger sets.
    Initialize an empty array using Compose and use another Compose to union the input array with the empty array.

    Union with empty array to get unique values.Union with empty array to get unique values.

     

  • Casper Profile Picture
    41 on at

    This is a great post and helped a lot thank you.  I want to add on that question.

    My scenario is this.  I have to Tables (Arrays) I want to compare. 

     

    But first I need to filter the Table BC to only have distinct Account numbers, the catch is I want the Account number (in this case CPA004) to retain the entry with the highest last entry number (4002), and discard the other CPA004 entries.

     

    Decsus_0-1715783302380.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard