How do I get a distinct list of values from a DS entity, for my dropdown?

Hello, I can’t seem to figure this portion out! Essentially, in UiPath Apps I have a Table, from Data service, where my STATUS column has a bunch of values.

I want to create a drop down so they can filter by the distinct status, so in the above image for example the drop down would have “PENDING: Document..” , “Sucess! Document Sent..” and “In Progress: Document..”, etc.

Currently I have it set like so:

And the issue is it grabs EVERY status:

I’ve tried doing
STATUS.Distinct.ToArray and that did not work :frowning:

@David_Hernandez2,

Can you try this expression in List source

Fetch(YourEntity).data.DistinctBy(Function(x) x.StatusField).ToListSource()

Replace entity and fields as per your entity.

Hi @David_Hernandez2

Try to use the Group By function instead of DISTINCT. Fetch your data from the Data Service, then apply GroupBy(“STATUS”) to group the data by unique status values. Bind the dropdown to these grouped values, allowing the user to filter the table based on distinct STATUS options.

You can also check below link,

Happy Automation

Save your entity to a tempvariable of type ListSouurce of Entity

Create another variable of Type Array of text and use below expression

tempvariable .data.Select(Function(x) x.Column).Distinct().ToArray

While using in Drop Down - use Array variable as the data source

@David_Hernandez2

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.