web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power app Sorting with...
Power Apps
Unanswered

Power app Sorting with exact criteria

(0) ShareShare
ReportReport
Posted on by 8

Hi all,

Hope anyone can help me out with the issue. So I have a gallery that contains a "Priority" column . I have set up a sorting button, what function should be that it sorts( when clicked) from Highest to lowest. At the moment it sorts but not from Highest to lowest. I dont even understand based on what criteria it is sorting now. (when soring button is clicked). 

What i did is :

 

Set up variables:

Set(varSortcolumn,"field_13");//sorting Priority Variable
Set(varSortDirection,SortOrder.Descending);  //sorting Priority variable
Set(varcustomSortorder,Switch("field_13","highest",1,"high",2,"medium",3,"low",4,5));
 
I tryied to add a collection,but turned it off:
ClearCollect(varcustomSortorder,
{Value:"highest",Order: 1},
{Value:"high",Order: 2},
{Value:"medium",Order: 3},
{Value:"low",Order: 4}
);
 
this is the formula that is set OnSelect button icon:
 
Set(varSortcolumn,"field_13");
Set(varSortDirection,
If(
    varSortDirection=SortOrder.Ascending,
    SortOrder.Descending,
    SortOrder.Ascending
))
 
And my gallery formula:
If(Checkbox_Overdue.Value=false,
SortByColumns(Filter(Requests,
If(Not(IsBlank(ComboBox_RequestType.Selected)),Request_Type in ComboBox_RequestType.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Subtype_Filter_2.Selected)), Request_Subtype in ComboBox_Subtype_Filter_2.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Priority.Selected)),Prioritization in ComboBox_Priority.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Status.Selected)),Status in ComboBox_Status.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Requestor.Selected)),Requestor_Name in ComboBox_Requestor.SelectedItems.Result,true),
If(Not(IsBlank(ComboBox_AssignedTo.Selected)),Assigned_To in ComboBox_AssignedTo.SelectedItems.Title,true),
If(Not(IsBlank(ComboBox_Complexity.Selected)),Complexity in ComboBox_Complexity.SelectedItems.ColumnStart,true),
If(Not(IsBlank(ComboBox_PIQuarter.Selected)),Prioritised_in_PI_quarter in ComboBox_PIQuarter.SelectedItems.ColumnStart,true),
If(Not(IsBlank(ComboBox_PIYear.Selected)),Prioritised_in_PI_year in ComboBox_PIYear.SelectedItems.ColumnStart,true),
If(Not(IsBlank('ComboBox_GIA/GC'.Selected)), GIA_Compliance_Issue in 'ComboBox_GIA/GC'.Selected.ColumnStart,true),
If(Not(IsBlank(txtIDFilter_ID.Text)), ID=Value(txtIDFilter_ID.Text),true),
If('Toggle2_Filter Comple_Rejected'.Value, Status <> "Rejected" && Status <> "Completed", true),
TextInput_FreeText.Text in Business_Value Or
TextInput_FreeText.Text in Request_Description Or
TextInput_FreeText.Text in Request_Name),
varSortcolumn,
varSortDirection),


SortByColumns(Filter(Requests,
If(Not(IsBlank(ComboBox_RequestType.Selected)),Request_Type in ComboBox_RequestType.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Subtype_Filter_2.Selected)), Request_Subtype in ComboBox_Subtype_Filter_2.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Priority.Selected)),Prioritization in ComboBox_Priority.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Status.Selected)),Status in ComboBox_Status.SelectedItems.Value,true),
If(Not(IsBlank(ComboBox_Requestor.Selected)),Requestor_Name in ComboBox_Requestor.SelectedItems.Result,true),
If(Not(IsBlank(ComboBox_AssignedTo.Selected)),Assigned_To in ComboBox_AssignedTo.SelectedItems.Title,true),
If(Not(IsBlank(ComboBox_Complexity.Selected)),Complexity in ComboBox_Complexity.SelectedItems.ColumnStart,true),
If(Not(IsBlank(ComboBox_PIQuarter.Selected)),Prioritised_in_PI_quarter in ComboBox_PIQuarter.SelectedItems.ColumnStart,true),
If(Not(IsBlank(ComboBox_PIYear.Selected)),Prioritised_in_PI_year in ComboBox_PIYear.SelectedItems.ColumnStart,true),
If(Not(IsBlank('ComboBox_GIA/GC'.Selected)), GIA_Compliance_Issue in 'ComboBox_GIA/GC'.Selected.ColumnStart,true),
If('Toggle2_Filter Comple_Rejected'.Value, Status <> "Rejected" && Status <> "Completed", true),
Status <> "Completed",
Status <> "Rejected",
DateDiff(Deadline,Today(),TimeUnit.Days)>=0,
DateDiff(Deadline,Today(),TimeUnit.Days)<=Value(TextInput_OverdueDays.Text),
If(Not(IsBlank(txtIDFilter_ID.Text)), ID=Value(txtIDFilter_ID.Text),true),
TextInput_FreeText.Text in Business_Value Or
TextInput_FreeText.Text in Request_Description Or
TextInput_FreeText.Text in Request_Name),
varSortcolumn,
varSortDirection))
 
now it sorts like this 
borisbrs_0-1717572636657.png

 

 

borisbrs_1-1717572667775.png

I would appreciate if someone could point me out on the mistake 

thank you for your time 

 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @borisbrs ,

    Try this format

    SortByColumns(
     AddColumns(
     Filter(
     Requests,
     YourFilterHere
     ),
     SortColumn,
     Switch(
     field_13,
     "highest",
     1,
     "high",
     2,
     "medium",
     3,
     "low",
     4,5
     )
     ),
     SortColumn,
     varSortDirection
    )

     

    Please click Accept as solution 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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • borisbrs Profile Picture
    8 on at

    Thank you very much for your time. So if i understood you correctly I made the updates.

    SortByColumns(
    AddColumns(
    Filter(
    Requests,
    Myfilters
    ),

          SortByColumns,
          Switch(
             field_13,
             "highest",
             1,
             "high",
             2,
             "medium",
             3,
             "low",
             4,5
          )
       ),
       "field_13",
       varSortDirection
    )
     
    But it still sorts not in the correct direction:
    borisbrs_0-1717583625274.pngborisbrs_1-1717583633146.png

     

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @borisbrs ,

    That is not what I posted - you need to sort by the added column SortColumn (you can call it whatever you want).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard