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 / SortOrder not working ...
Power Apps
Unanswered

SortOrder not working correctly

(0) ShareShare
ReportReport
Posted on by 19

Hello, all - 

 

I'm having some difficulty getting a gallery to sort in the specified order - PowerApps for Teams & Dataverse for Teams.

 

Here's some code that works: 

 

Sort(
 Filter(
 Caseloads, 
 clPatient.ptCampus = intCampus && 
 clDiscipline = intDiscipline && 
 Status = 'Status (Caseloads)'.Active && 
 Or(
 clTherapist.Therapist = guidFilterTherapists, 
 IsBlank(guidFilterTherapists)
 ) &&
 Or(
 clStudent.Therapist = guidFilterStudents, 
 IsBlank(guidFilterStudents)
 ) &&
 Or(
 clPatient.ptWard = strFilterWard, 
 IsBlank(strFilterWard)
 ) && 
 Or(
 clPatient.ptService = strFilterService, 
 IsBlank(strFilterService)
 ) &&
 Or(
 !blnFilterPickup,
 clPickup = 1
 )
 ),
 clPtName, 
 SortOrder.Descending
 )

 

 

However, if I use a WITH statement, it does not work - it does not error, it just doesn't sort descending: 

With(
 {
 recTest:
 Filter(
 Caseloads, 
 clPatient.ptCampus = intCampus && 
 clDiscipline = intDiscipline && 
 Status = 'Status (Caseloads)'.Active && 
 Or(
 clTherapist.Therapist = guidFilterTherapists, 
 IsBlank(guidFilterTherapists)
 ) &&
 Or(
 clStudent.Therapist = guidFilterStudents, 
 IsBlank(guidFilterStudents)
 ) &&
 Or(
 clPatient.ptWard = strFilterWard, 
 IsBlank(strFilterWard)
 ) && 
 Or(
 clPatient.ptService = strFilterService, 
 IsBlank(strFilterService)
 ) &&
 Or(
 !blnFilterPickup,
 clPickup = 1
 )
 )
 },
 Sort(recTest, clPtName, SortOrder.Descending)
)

 

Do you have any thoughts?  (Also, I've read other questions where people have said that you don't need to use SortOrder.Descending, you can just use Descending, but I get an error if I try this.)

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    on at

    Hi @elodonnell ,

     

    What are these:

    intCampus 

    intDiscipline

    guidFilterTherapists

    guidFilterStudents

    strFilterWard

    strFilterService

     

    They look like various controls, don't they? If they are controls, you need to reference specific properties of respective controls, other than reference controls themselves.

     

    Best regards,

  • elodonnell Profile Picture
    19 on at

    Hi, @v-jefferni -

     

    Thanks for your response, those are just variables that have been set previously via UpdateContext.  I could certainly understand if those were controls that I'd need to reference their properties, although this is not the case for the code above. 

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