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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filter array of object...
Power Automate
Unanswered

Filter array of objects based on value within the objects

(0) ShareShare
ReportReport
Posted on by 4

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!

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,678 Most Valuable Professional on at
    Re: Filter array of objects based on value within the objects

    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

  • AS-17120854-0 Profile Picture
    4 on at
    Re: Filter array of objects based on value within the objects

    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: 

    AaronLuis_0-1638056833675.png

     

    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!

     

  • Pstork1 Profile Picture
    68,678 Most Valuable Professional on at
    Re: Filter array of objects based on value within the objects

    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?

  • AS-17120854-0 Profile Picture
    4 on at
    Re: Filter array of objects based on value within the objects

    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.

  • takolota1 Profile Picture
    4,974 Moderator on at
    Re: Filter array of objects based on value within the objects

    This template identifies & removes duplicates from any JSON array: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Find-and-Remove-Duplicates/m-p/2191403#M1611

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 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard