cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JRaasumaa
Level 10

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
Community Support Team
Community Support Team

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.
mx
Level 8

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

cool. Logged and noted.

 

DatabaseMX ('mx')
Microsoft Access MVP
jesenavaranjan
Level: Powered On

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 87 members 3,350 guests
Please welcome our newest community members: