I’ve been struggling for a while, yet I sorted it out. Wooohooo.
The challenge
I’ve been trying to populate a drop down list in a Powerapp application. The source is a column called “Category” in an Excel document stored on OneDrive. The Category column contains redundant data and empty records. The drop down list has to be populated with single occurrence of categories and but not show an empty line. I want them the list to be alphabetically sorted.
The solution
It requires to encapsulate multiple functions. This is the function you have to put in your “Items” field for the drop down.
SortByColumns(Distinct(Table1,If(Not(IsBlank(Category)),Category)),"Result")
Table1 is my source table. Category is my source column (or field). Not(IsBlank(Category)) will collect the full list except blank records. Distinct will then remove duplicates from the list. Finally, SortByColumns will sort the results based on the Category field. By default, sorting will be ascending.
Here we are.