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 a Gallery tem by ...
Power Apps
Unanswered

Sort a Gallery tem by Time

(0) ShareShare
ReportReport
Posted on by 10

Hi, I want to sort a gallery items by time Ascending or Descending (Date_Time column in Sharepoint List). Pls help me.

Ex: 26/12/2021 14:00

     26/12/2021  08:30

     26/12/2021 11:00

     26/12/2021 09:15

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

    Hi @BuiDucNghia ,

    Put a button on the screen with

    UpdateContext({varSortOrder:!varSortOrder})

    then your gallery Items

    Sort(
     YouSPListName,
     YourDateTimeField,
     If(
     varSortOrder,
     Descending,
     Ascending
     )
    )

     

    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.

    Visit my blog Practical Power Apps 

  • BuiDucNghia Profile Picture
    10 on at

    Thanks @WarrenBelz 

    I  want to sort a gallery by time the same day as pic attachment.

    IMG-5256.jpg

    My code in Gallery Items: If(
    IsBlank(colSelectedDate), //if gallery not select, filter Gallery is Today
    SortByColumns(
    Filter(
    colLichTuan, txtSearchLichTuan.Text in DateValue(Text(ThoiGian)),
    //ThoiGian: DateTime Column in Sharepoint List
    DateTimeValue(Text(ThoiGian, ShortDateTime24)) >= Today(),
    DateTimeValue(Text(ThoiGian, ShortDateTime24)) < DateAdd(Today(),1,Days)
    ), "ThoiGian", Ascending // want to sort by time here as Pic.
    ),
    WeekdayGallery_1.Selected.LichHop_grp
    )
  • WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @BuiDucNghia ,

    I have not addressed your If logic as it is not clear to me, but for the rest if you want to sort by Time on the date selected

    If(
     IsBlank(colSelectedDate), //if gallery not select, filter Gallery is Today
     SortByColumns(
     Filter(
     AddColumns(
     colLichTuan,
     "TimeSort",
     Text(ThoiGian,"hh:mm")
     ), 			
     txtSearchLichTuan.Text in Text(ThoiGian,"dd/mm/yyyy) ||
     Text(ThoiGian,"dd/mm/yyyy") = Text(Today(),"dd/mm/yyyy")
     ), 
     "TimeSort",
     If(
     varSortOrder,	 
     Descending,
     Ascending 
     )
     ),
     WeekdayGallery_1.Selected.LichHop_grp
    )

     

    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.

    Visit my blog Practical Power Apps

  • BuiDucNghia Profile Picture
    10 on at

    Thanks for your help, but still not work 😞

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

    @BuiDucNghia ,

    "Not work" does not really help me - are you getting any errors - if so what are they. 

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 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard