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 Gallery by button
Power Apps
Answered

Sort Gallery by button

(0) ShareShare
ReportReport
Posted on by 728

Hello,

 

I have a gallery that has the following formula on the Items property:

Sort(
Filter(
Records,
WITHDRAWN = false,
StartsWith(
Title,
TextInput1.Text
) || StartsWith(
'StudentNo ',
TextInput1.Text
)
),
Created,SortOrder.Ascending
)

 

I was wondering if it is possible to add a Sort button so when pressed, it will then sort the gallery by name (column is the Title field in sharepoint).

 

Default sort and filter is as shown above, but if you click on a sort button then it will sort the list by Title and alphabetical, then have a reset option to switch back to default sort.

Can anyone help or advise how i can achieve this?

 

thanks

Categories:
I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @neill_long - one method:

     

    On the OnSelect property of your Button control, enter:

     

    UpdateContext({ctx_sort_column: "Title"});
    UpdateContext({ctx_sort_order: !ctx_sort_order})

     

    On the OnSelect property of your reset Button, enter:

     

    UpdateContext({ctx_sort_column: "Created"});
    UpdateContext({ctx_sort_order: true})

     

    The modify the Items property of your Gallery to:

     

    SortByColumns(
     Filter(
     Records,
     !WITHDRAWN, //cleaned up. this has nothing to do with your question
     StartsWith(
     Title,
     TextInput1.Text
     ) || StartsWith(
     'StudentNo ',
     TextInput1.Text
     )
     ),
     ctx_sort_column,
     If(
     ctx_sort_order,
     SortOrder.Ascending,
     SortOrder.Descending
     )
    )

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard