Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Sorting in a Gallery

(0) ShareShare
ReportReport
Posted on by 4
Hi,
 
I've got a Gallery displaying items from a Sharepoint List (currenlty 13 items in the list)
Currently Item is set to: my sharepoint list 
    'Proof of delivery'
But it's seems that if I apply this formula in order to sort the item by creation date:

SortByColumns('Proof of delivery',"Created",Descending)

 

Or even this one to display only 10 items.

FirstN(SortByColumns('Proof of delivery',"Created",Descending),10)

 
I've go the error:
The function 'SortByCollumns' has some invalid arguments.
It's seems that Power App has some restriction for long list (above 2000 items) and type of fields or type of complexe function but as per below. I shouldn't have any problem.
 
Anyone got a clue ?
 
Thx
 

 

 
 
Screenshot 2025-0...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

  • stampcoin Profile Picture
    2,133 on at
    Sorting in a Gallery
    For your dropdown, If SWAPStatus is not  choices column.
    SortByColumns(
        Filter(
            'OTR 2025 List',SWAPStatus <> "SWAP Complete" && SWAPStatus <> "Cancelled"),
                "TrID",Sort.OrderDescending //there is a dot after Sort
    )
    If it is choices column.
    SortByColumns(
        Filter(
            'OTR 2025 List',SWAPStatus.Value <> "SWAP Complete" && SWAPStatus.Value <> "Cancelled"),
                "TrID",Sort.OrderDescending
    )
    Again, you might get delegation warning.
  • AV-03060611-0 Profile Picture
    4 on at
    Sorting in a Gallery
    You guys are great.
    I've got a similar issue with dropdown list that I would like sorter by TrID and filter out when SWAPStatus is "Cancelled" or "SWAP Complete"
     
    I've tried this (with your awesome advices)

    SortByColumns(Filter('OTR 2025 List',SWAPStatus <> "SWAP Complete" && SWAPStatus <> "Cancelled"), "TrID",SortOrderDescending)

    But it does neither of both.
     

     

  • stampcoin Profile Picture
    2,133 on at
    Sorting in a Gallery
    Thanks for pointing that out. I was wrong regarding SortByColumns.
    SortByColumns function takes double quotes when refers to the column name.
    Sort function takes single quote if column name has space, or without quote if no spaces on the name.
    btw, I like your template comment. 👍
  • MarkRahn Profile Picture
    1,049 Super User 2025 Season 1 on at
    Sorting in a Gallery
    Hi,
     
    @stampcoin has the correct answer. Power Apps sometimes abbreviates the code so it shows "SortOrder.Descending" as "Descending" which does not make Copy/Paste work very well.
     
    Both of your formulas will work if you change "Descending" to "SortOrder.Descending"
     
    This worked for me in the example I tried:
     
    FirstN(SortByColumns('Proof of delivery',"Created",SortOrder.Descending),10)
     
    Regarding results returned, if you can get your query to be "delegateable" - meaning that the data source handles the query and not the Power App - then even though you are only getting a max of 2000 results; they would be the top 2000 results returned where SharePoint had sorted the List descending by "Created". Make sure you put an Index on "Created". You could also use "ID" and you would get the same results and "ID" is Indexed by SharePoint.
     
    This community is supported by individuals freely devoting their time to answer questions and provide support. They do it to let you know you are not alone. This is a community.

    If someone has been able to answer your questions or solve your problem, please click Does this answer your question. This will help others who have the same question find a solution quickly via the forum search.

    If someone was able to provide you with more information that moved you closer to a solution, throw them a Like. It might make their day. 😊

    Thanks
    -Mark
  • Verified answer
    stampcoin Profile Picture
    2,133 on at
    Sorting in a Gallery
     
    Please try this:
    SortByColumns('Proof of delivery',Created,SortOrder.Descending)
     
    I think You don't need double quote for  Created.
    You already know that it will be a problem that if you have much more data in SharePoint list.
     

    Enjoy Power Platform and have a great day 🚀 |  My LinkedIn

    If the answer helps, please consider 👍, Thanks.

     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >