Showing results for 
Search instead for 
Did you mean: 
New Member

Filter array of objects based on value within the objects

We are having trouble with a flow where we need to filter an array of objects.


So this is the use case: 

- We are starting with a list rows from an excel table (the table has multilple rows with multiple columns which store information we need later on in the flow)

- There are two filter array actions to filter the list of values coming from the list rows action (first filter is for country codes and second filter is the exclude internal entries based on internal email addresses)

- After the two filter array actions, the output of the list rows action is nearly where we need it 

- The array has multiple objects in it with different values coming from the excel table (such as first name and last name of a contact, the company name, the email address or the department code)

- But we have the case where we have two or more objects where the email address is identical

- We only need the first or a unique object for one email address (so for example: we have 10 objects in the array where in three objects the email address is the same. We need to exclude the two "double" objects with the identical email address to reduce the array to 8 objects with only unique email addresses)

- We already tried a compose with the union function based on the email address, but with that all the other information within the objects we took from the excel file is lost and we need that information


So the general question is how can we filter an array of objects based on a single value within the objects (in our case the email address).


Thank you guys in advance for assistance!

Dual Super User
Dual Super User

Try using the Union() function to filter the array down to the unique values present in the array.  This blog post explains.

Get Distinct Records using the union expression in Power Automate - That API Guy

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

Thank you for the quick response, I already tried the union function, but it did not work as expected. 


This is how the array looks like: 



As you can see, the array contains multiple objects with different data in it. I can use the union function on the email address here, but my output only contains the email adresses and all the other data is missing. 


I hope you can understand what I mean!


There will be no way to keep multiple copies of the other data if you weed out the records with the same email addresses.  The best you would be able to do is retain the first record's values for each distinct email.  Are you trying to keep all the record values or just the first distinct record?

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

It would be enough just to keep the first distinct record per email address. The other objects with the same email address can be deleted out of the array, that won't be a problem.

Helpful resources

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

AI Builder AMA June 7th carousel (up on May 25th, take down June 8th) (1).png

'Ask Microsoft Anything' about AI Builder!

The AI Builder team invite you to ask questions and provide helpful answers at our next AMA.

Users online (1,902)