Dear Power apps experts,
I have created an App using a gallary which is connected to SP list as "data source".
I am trying to create a combobox and combaine two functions (Distinct and sort) but not successed yet.
The combobox supposes to show a list of values from a column in the data source (table from SP). The values must be sorted based on another column. For instance, If we suppose that we have two columns on SP list, column A and B. I what is want to do is, to connect the comobobox to column A as dropdown list and to be sorted (Descending) based on column B.
A (Serie nr) | B (ID) |
10 | 5 |
7 | 4 |
5 | 3 |
11 | 2 |
3 | 1 |
With other word, I want to create the combobox to have the dropdown list A (Serie nr) and sorted on B (ID), however; the dropdown list should show the results as folowing:
A (Serie nr) |
3 |
11 |
5 |
7 |
10 |
I would appreciate your help.
BR
It worked very well!
Thank you a lot, very apprecieted 🙏
Hi @Appsforourlife ,
My first try would be to use GroupBy instead of Distinct so the rest of the data is preserved and can be used for sorting:
Sort(
AddColumns(
GroupBy(
DataSourceName,
"ColumnA",
"GroupedByA"
),
"SortOrder",
First(GroupedByA).ColumnB
),
SortOrder
)
Distinct(SortByColumns(DataSource,"ColumnB",SortOrder.Descending),ColumnA)
Try this Out
Please click Accept as solution and Thumbs Up. if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.