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.
Thanks for the sharing!
Regards,
Michael
cool. Logged and noted.
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
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
184 | |
53 | |
41 | |
36 | |
30 |
User | Count |
---|---|
240 | |
74 | |
71 | |
69 | |
65 |