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 / Sort while having If a...
Power Apps
Answered

Sort while having If and Filter statements

(0) ShareShare
ReportReport
Posted on by 302

Hey there,
I currently have this on my Gallery1, how would I add a sort feature to this? 
I set my Up Arrow's OnSelect to Set(SortAscending, true) and my Down Arrow's OnSelect to Set(SortAscending, false) 
I would like to sort by the column, TicketNumber.

If(
//This is for All + Not completed
 ddName.Selected.Result = "All" And ddCompleted.Selected.Value = "Not Completed",
 Filter(
 'Nascentia Neighborhood Work Order List',
 Completedd = ddCompleted.Selected.Value
 ),
//This is for All + Completed
 ddName.Selected.Result = "All" And ddCompleted.Selected.Value = "Completed",
 Filter(
 'Nascentia Neighborhood Work Order List',
 Completedd = ddCompleted.Selected.Value
 ),
//This is for Selected Assigned + Not Completed
 ddName.Selected.Result <> "All" And ddCompleted.Selected.Value = "Not Completed",
 Filter(
 'Nascentia Neighborhood Work Order List', Assigned = ddName.Selected.Result And Completedd = ddCompleted.Selected.Value),
//This is for Selected Assigned + Completed
 ddName.Selected.Result <> "All" And ddCompleted.Selected.Value = "Completed",
 Filter(
 'Nascentia Neighborhood Work Order List', Assigned = ddName.Selected.Result And Completedd = ddCompleted.Selected.Value)
)

 

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @honganhuynh1,

     

    In order to avoid code repetition we can actually remove the If() statement and adjust the Filter() to achieve a similar result. In order to sort the Filter() response, we will enclose the filter function with a Sort() function:

     

    Sort(
     Filter(
     'Nascentia Neighborhood Work Order List',
     //Filter by ddCompleted value
     Completedd = ddCompleted.Selected.Value,
     //Then filter by ddName if All is not selected
     ddName.Selected.Result = "All" || Assigned = ddName.Selected.Result
     ),
     TicketNumber, 
     If(SortAscending, Ascending,Descending)
    )

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

  • honganhuynh1 Profile Picture
    302 on at

    Thank you!!!

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 321 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 289 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 200 Super User 2026 Season 1

Last 30 days Overall leaderboard