cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: Dropdown list with distinct values and option for "All"

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.
Highlighted
Advocate III
Advocate III

Re: Dropdown list with distinct values and option for "All"

cool. Logged and noted.

 

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

Re: Dropdown list with distinct values and option for "All"

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
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,136)