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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApps is not sorti...
Power Apps
Answered

PowerApps is not sorting! HELP!

(0) ShareShare
ReportReport
Posted on by 26

Please tell me why this is not sorting correctly. I do not understand 😞

 

SortByColumns( 
 AddColumns(
 Filter('Employees Database - test(Overtime Tracker)', manager = User().FullName),
 "decision",
 LookUp(
 colOvertimeDatabase,
 full_name = first_Name&" "&last_Name && month = glbThisMonth && financial_Year = glbThisYear
 ).second_Approval.Value
 ) 
 ,
 "decision", [Blank(),"Pending","Rejected","Approved"]
)

 

 
Categories:
I have the same question (0)
  • MrLaska Profile Picture
    26 on at

    BTW, there is blank Value there, i checked:

    MrLaska_0-1709927995261.png

     

  • Verified answer
    a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Hello,

    There might be a better way (cause I'm quite fresh with CanvasApps and PowerFX). Here is what I did - I artificially added the column of decision weight and used it for the sorting:

     

     

    SortByColumns(
     AddColumns(
     values,
     "decisionweight",
     If(
     IsBlank(decision),
     1,
     Switch(
     decision,
     "Pending",
     2,
     "Rejected",
     3,
     "Approved",
     4
     )
     )
     ),
     "decisionweight"
    )

     

    I hope the direction I took is clear.

     

    Here is my initialization of the collection:

    ClearCollect(
     values,
     {
     id: GUID(),
     name: "First",
     decision: Blank()
     },
     {
     id: GUID(),
     name: "Second",
     decision: "Approved"
     },
     {
     id: GUID(),
     name: "Third",
     decision: "Pending"
     },
     {
     id: GUID(),
     name: "Fourth",
     decision: "Rejected"
     },
     {
     id: GUID(),
     name: "Second2",
     decision: "Approved"
     },
     {
     id: GUID(),
     name: "Third3",
     decision: "Pending"
     },
     {
     id: GUID(),
     name: "Fourth4",
     decision: "Rejected"
     }
    )

    Here is how it sorted the result:

    a33ik_0-1709929959778.png

     

  • MrLaska Profile Picture
    26 on at

    This is in Gallery 'Item' property. I will wait for other suggestions but Thank You 🙂

  • Verified answer
    WarrenBelz Profile Picture
    156,409 Most Valuable Professional on at

    @MrLaska ,

    The direction @a33ik has taken is correct - you simply need to add it to your gallery

    SortByColumns( 
     AddColumns(
     AddColumns(
     Filter(
     'Employees Database - test(Overtime Tracker)', 
     manager = User().FullName
     ),
     "decision",
     LookUp(
     colOvertimeDatabase,
     full_name = first_Name & " " & last_Name && 
     month = glbThisMonth && 
     financial_Year = glbThisYear
     ).second_Approval.Value
     ),
     "SortCol",
     Switch(
     decision,
     Blank(),
     1,
     "Pending",
     2,
     "Rejected",
     3,
     "Approved",
     4,
     5
     )
     ),
     "SortCol",
     SortOrder.Ascending
    )

     

  • MrLaska Profile Picture
    26 on at

    Unfortunately it comes out as an error:

     

    MrLaska_0-1709977648288.png

     

  • WarrenBelz Profile Picture
    156,409 Most Valuable Professional on at

    @MrLaska ,

    Bracket in wrong place - code now amended

  • MrLaska Profile Picture
    26 on at

    It works! Thank You very much. You're a star.

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    @MrLaska lol. I gave you an answer and didn't get my answer as verified.

  • WarrenBelz Profile Picture
    156,409 Most Valuable Professional on at

    @a33ik ,

    I have marked it for you.

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    @WarrenBelz Thanks. Not that I desperately need those points but I believe it's fair to mark as verified an answer 🙂

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard