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 / Sorting a Gallery usin...
Power Apps
Unanswered

Sorting a Gallery using multiple Columns

(0) ShareShare
ReportReport
Posted on by 183

Hello all,

 

I am trying something that I just can't quite get right. I'm attempting to sort my Gallery View of a Sharepoint list on a few separate columns. 

 

This is how I currently have it set:

 

SortByColumns(Filter([@'Regular Log'], StartsWith(LastName, TextSearchBox1_1.Text)), "DateTimeofPage", If(SortDescending1, Ascending, Descending))

 

The DateTimeofPage is really just a Date field. They are using an older Sharepoint list and the Columns are set up somewhat funky. Ideally, they would like the DateTimeofPage (date) followed by Time of Page Hours (hour) then Time of Page Minutes (minutes) in that order to get their gallery view to show the most recent entry followed by older entries.

 

So it would be a MM-DD-YYYY, H, M ordering scheme.

 

Any help would be appreciated!

Categories:
  • WarrenBelz Profile Picture
    156,538 Most Valuable Professional on at

    @NathanFra ,

    If DateTimeofPage is a date/time field, it should work with your code. Is it in some other format?

  • NathanFra Profile Picture
    183 on at

    @WarrenBelz ,

     

    When this list was made, they did that column as a date only field. Which is why they made separate entry fields (SharePoint columns) for both Hour and Minute. 

     

    Not how I would have done it, but its a list they have been using for a long time so I don't want to change any of that on them.

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

    Hi @NathanFra ,

    Try

    SortByColumns(
     Filter(
     [@'Regular Log'], 
     StartsWith(
     LastName, 
     TextSearchBox1_1.Text
     )
     ),
     "DateTimeofPage",
     Descending,
     "Time of Page Hours (hour)",
     Descending,
     "Time of Page Minutes (minutes)",
     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.

  • NathanFra Profile Picture
    183 on at

    @WarrenBelz 

     

    No luck 😞

     

    I even tried going into the list settings and copied the end of the column URL thinking that might have some change:

     

    SortByColumns(
    Filter(
    [@'Regular Log'],
    StartsWith(
    LastName,
    TextSearchBox1_1.Text
    )
    ),
    "DateTimeofPage",
    Descending,
    "Time_x0020_of_x0020_Page_x0020_H",
    Descending,
    "Time_x0020_of_x0020_Page_x0020_M",
    Descending
    )

  • NathanFra Profile Picture
    183 on at

    @WarrenBelz 

     

    Screen shot of columns. I did take the (s) and the (hour/minute) out of the original code.

     

     

    Full code.PNG
    Date Time issue.PNG
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @NathanFra :

    You fromula looks fine.I made a similar test but did not encounted the problem you mentioned:

    1\My data source

    1.JPG

    2\Add a gallery and set it's items property to:

    SortByColumns(
     'Regular Log',
     "DateTimeofPage",
     Descending,
     "TimeofPageH",
     Descending,
     "TimeofPageM",
     Descending
    )

    This formula worked well.

    I think the reason for your error is the unrecognizable space in the field name.Please try:

    SortByColumns(
    Filter(
    [@'Regular Log'],
    StartsWith(
    LastName,
    TextSearchBox1_1.Text
    )
    ),
    "DateTimeofPage",
    Descending,
    "TimeofPageH",
    Descending,
    "TimeofPageM",
    Descending
    )

    I suggest you save this list to a collection, and then check the data structure of the table. You should be able to find that the spaces in the field name have been deleted.

    ClearCollect(
    TheCollection,
    Filter(
    [@'Regular Log'],
    StartsWith(
    LastName,
    TextSearchBox1_1.Text
    ))

     Best Regards,

    Bof

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard