cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TeresaRey
Frequent Visitor

Removing Array Duplicates

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? 

2 ACCEPTED SOLUTIONS

Accepted Solutions

@TeresaRey 

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!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

yashkamdar
Solution Sage
Solution Sage

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!

 

View solution in original post

6 REPLIES 6
efialttes
Super User
Super User

Hi!

I would suggest to use union() WDL function

Give me some minutes to write a clear example



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



@TeresaRey 

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!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



yashkamdar
Solution Sage
Solution Sage

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!

 

Thank you very much for the detailed explanation.

 

This worked as expected.

Thabnk you very much, this was very usefull!

ManiLive
Advocate I
Advocate I

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.

 

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,605)