cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JRaasumaa
Memorable Member
Memorable Member

Dropdown list with distinct values and option for "All"

I wanted to share this technique I've been using to create a dropdown from a datasource as well as include an option for "All"

 

There are 3 steps, 1st collect the word "All" into your dropdown list named collection with ClearCollect

 

 

ClearCollect(DropList, {Result:"All"})

Make sure to collect the word "All" in a column "Result" (this is important to name it Result)

 

 

2nd, Use a regular Collect of the data source's distinct values. I typically filter the data as well as sort.

 

 

Collect(DropList, Sort(Distinct(Filter('DatasourceHere',Project <> ""),Project),Result,Ascending))

This collection does a few things, it filters out the DataSourceHere by something, in this case items without a blank string.It also gathers only distinct values, in this case distinct Project column values. Then last it sorts the filtered data set by a column, because it's a Distinct filter of the data the column it creates is named "Result", and that's what it is sorting Ascending by.

 

 

 

3rd, put the DropList name in the dropdown as it's item's property.

 

 

You will want to combine these in a way the list can be loaded on screen visible property or with a button press etc. I always put these two items back to back.

 

ClearCollect(DropList, {Result:"All"});Collect(DropList, Sort(Distinct(Filter('DatasourceHere',Project <> ""),Project),Result,Ascending))

 

By doing this you can use the "Results" column to build a dynamic dropdown list with unique sorted values from a datasource as well as have an option "All" at the top of the dropdown giving the end user a great filtering or sorting tool!

 

 

Let me know if anyone has questions, hopefully this is helpful.

 

 

3 REPLIES 3
v-micsh-msft
Community Support
Community Support

Thanks for the sharing!

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mx
Advocate III
Advocate III

cool. Logged and noted.

 

DatabaseMX ('mx')
Microsoft Access MVP
jesenavaranjan
Helper V
Helper V

ClearCollect(DList, {Result:"All"});Collect(DList, Sort(Distinct('[dbo].[tbOrgStructure]',D),Ascending)) I'm doing this in my On Start for the App but my app is showing empty values.

 

Any ideas why?

Please and thank you

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (5,358)