So you have an array in Power Automate with duplicates, what is the easiest way to remove these duplicates? This blog post will show you how easy it is to do in a single action.
Firstly, I’m assuming you already have your array, for my example I’ll be using email addresses for a mailing list which contains duplicates. The array is shown below:
[ "email@example.com", "firstname.lastname@example.org", "email@example.com", "firstname.lastname@example.org", "email@example.com", "firstname.lastname@example.org", "email@example.com", "firstname.lastname@example.org" ]
As you can see, we have 3x email@example.com and 2x firstname.lastname@example.org, we want to remove these duplicates and just have individual emails for our mailing list.
So how do we remove these duplicates quickly, efficiently and easily? We can simply use a Compose action and the Union function. While using the Union function we pass the same array into it twice. This causes Power Automate to think we’re merging two arrays (even though it’s the same array!) and removes the duplicates. This then leaves us with a final, duplicate free array, from the output of the compose action.
The Union code in this instance is:
Now lets take a look at what the output is after the flow has run:
And there you have it, an array without duplicates using a single action and a single function.
If you’re looking to learn more about Power Automate functions, like the Union function used in this post, you can use then check this blog post list out: Power Automate Functions
Alternatively if you’re looking for videos to explain functions on Power Automate, check out my YouTube channel: https://youtube.com/c/FlowJoeVideos