cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nich3play3r
Advocate II
Advocate II

Can't get unique values from array based on List Rows step

Hi.

 

I'm stuck on a flow. I have a List rows present in a table step that then connects to an initialize variable step that creates an array from the values in the List rows step. Then I filter out empty values from the array in the next step. All is well at this point.

 

Next, I'd like to get distinct values for one value in my filtered array, but I'm running up against the issue that my array values look like this:

 

{
    "@odata.etag": "",
    "ItemInternalId": "94a771a7-7f42-4e9f-a12b-820f08814189",
    "AssignedEmail": "person.one@email.org"
  },
  {
    "@odata.etag": "",
    "ItemInternalId": "901c1c63-a776-4968-85b3-141d96653a82",
    "AssignedEmail": "person.one@email.org"
  },

That ItemInternalId is making it so that I have no distinct values in my array. How do I dedupe based on the AssignedEmail value?

 

Thanks for any assistance you can provide!

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

You can use the Union function to return a distinct or unique set of email addresses.

For example, using the following Excel table containing multiple duplicate email address in the AssignedEmail column:

2021-12-11_10-03-24.png

We can write a flow to select only the AssignedEmail column, then use the Union function to remove the duplicates:

2021-12-11_10-10-19.png

union(body('Select'),body('Select'))

 

This is the runtime output of the Select action which selects only the AssignedEmail column:2021-12-11_09-58-52.png

 

Then we use the Union function to remove duplicate email addresses, which returns an array of distinct email addresses:

2021-12-11_10-01-41.png

 


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

View solution in original post

6 REPLIES 6
ekarim2020
Super User
Super User

You can use the Union function to return a distinct or unique set of email addresses.

For example, using the following Excel table containing multiple duplicate email address in the AssignedEmail column:

2021-12-11_10-03-24.png

We can write a flow to select only the AssignedEmail column, then use the Union function to remove the duplicates:

2021-12-11_10-10-19.png

union(body('Select'),body('Select'))

 

This is the runtime output of the Select action which selects only the AssignedEmail column:2021-12-11_09-58-52.png

 

Then we use the Union function to remove duplicate email addresses, which returns an array of distinct email addresses:

2021-12-11_10-01-41.png

 


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

nich3play3r
Advocate II
Advocate II

Thanks so much for this reply, @ekarim2020 . I think something must be going wrong between my List rows and Select actions. Here's an excerpt of the head of the output from List rows:

[
  {
    "@odata.etag": "",
    "ItemInternalId": "6a943c2e-7768-4264-bc6d-e92ee264dc20",
    "AssignedEmail": "person.one@email.org"
  },
  {
    "@odata.etag": "",
    "ItemInternalId": "87fc7c33-da2b-4c91-92db-196cc3184404",
    "AssignedEmail": "person.two@email.org"
  },
  {
    "@odata.etag": "",
    "ItemInternalId": "fec1312c-2d34-49d7-a7e9-a37b430c273a",
    "AssignedEmail": "person.two@email.org"
  },

When I get to my Select action, I'm not seeing my AssignedEmail field in dynamic content:

select.png

[Updated] For your flow, you will need to enter an expression for the AssignedEmail column:

 

2021-12-11_18-19-25.png


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

Yup, that did it, @ekarim2020 . No wonder you're a Community Champion!

 

Where in this flow would you implement the expression to filter empty values? I know I could add a step after the compose, but would it make more sense to do it prior to the Compose action?

 

Thanks so much for your help with this; I'velearned a lot.

You can try this method to filter out empty email addresses:

2021-12-11_17-52-53.png

 


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

Turns out this worked:

filter_empty.png

 

equals(empty(item()?['AssignedEmail']), bool('False'))

 

Thanks again for the help, @ekarim2020 !

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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.

Users online (1,218)