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!
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
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?
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.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Read the latest about new experiences and capabilities in the Power Automate product blog.
If you are a small business ISV/Reseller, share your thoughts with our research team.
User | Count |
---|---|
26 | |
25 | |
23 | |
22 | |
14 |
User | Count |
---|---|
49 | |
36 | |
36 | |
31 | |
30 |