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
Super User II
Super User II

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 III
Super User III

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!



View solution in original post

yashkamdar
Super User II
Super User II

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

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Kudoed Authors
Users online (2,119)