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 / Sort By Date in Ascend...
Power Apps
Answered

Sort By Date in Ascending Order

(0) ShareShare
ReportReport
Posted on by 135

Me again, I have some code here that I am filtering and putting in the gallery, but now I want to sort the gallery by the date column in descending order (so the earliest to oldest) . Here is what I have come up with. The Data type for the Date column is Date and Time, with a Date only format. 

 

Right now, the gallery shows as:

7/8/2022

1/5/2023

12/15/2022.

 

The expected result should be:

1/5/2023

12/15/2022

7/8/2022

 

 

 

 

Clear(Exa);
Collect(
 Exa,
 
 Sort(Filter(
 'db.Di',
 L1 = varL1 && L2 = varL2 && L3 = varL3 && L4 = varL4 && Source = "Ins"
 ), Date, Descending)
);

 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at

    Hi @Jeffclark ,

    Apart from Date being a bad name for a field (it is a Reserved Word in Power Apps), if the field is Date/Time, this should sort in the order you have specified

    ClearCollect(
     Exa,
     Sort(
     Filter(
     'db.Di',
     L1 = varL1 && L2 = varL2 && L3 = varL3 && L4 = varL4 && Source = "Ins"
     ), 
     Date, 
     Descending
     )
    );

    As a test, put this as the Items of a Gallery and see what you receive.

    Sort(
     Filter(
     'db.Di',
     L1 = varL1 && L2 = varL2 && L3 = varL3 && L4 = varL4 && Source = "Ins"
     ), 
     Date, 
     Descending
    )

     

    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

     

  • Jeffclark Profile Picture
    135 on at

    @WarrenBelz you're the best. I also see where on my side I was going wrong. In the items I was using a different collection that didnt contain the sort.

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard