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 / Filtering and Sorting ...
Power Apps
Answered

Filtering and Sorting a gallery

(0) ShareShare
ReportReport
Posted on by 4

I am new to PowerApps so please be patient with me.  🙂  I am working with a SharePoint list which is used for logging training sessions.  The gallery shows a record ID number called ID, a Text field called Skill, Created date, and Text Field called location.

 

I can search based on record ID number successfully.  For this I have the following in the Gallery Item:

If(IsBlank(TextSearchBox1.Text), Logs, Filter(Logs, TextSearchBox1.Text in Text(ID))) 

 

I want to also be able to Sort Ascending and Descending by ID field by clicking on the icon.

 

I have spent several days going over all the entries and trying out all the solutions (sort, sortby columns, ect., but everytime I try any of the solutions all the records disappear from my gallery.  What am I missing?  Any suggestion would be very appreciated.  

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You'll want to use the SortByColumns function for that. The first parameter of that function takes a "table", which can be either a data source directly, or the result of any other expression that also returns a table. It turns out that your If expression does return a table (since you can set it to the Items property of the gallery), so you should be able to use something along the lines of:

    SortByColumns(
     If(
     IsBlank(TextSearchBox1.Text),
     Logs,
     Filter(Logs, TextSearchBox1.Text in Text(ID))),
     "ID",
     If(sortDescending, Descending, Ascending))

    Where "sortDescending" is a variable that you can toggle by setting the following expression in the ascending/descending icon:

    UpdateContext({sortDescending: !sortDescending})
  • thutzler Profile Picture
    4 on at

    Yes!  That worked!

     

    Thank you so much for your help.  I was on the right track looks like, but l the column I was trying to use wasn't acceptable.  When I saw what you had a light went off and I tried a different column and worked fine.  I even have it searching on one column and sorting on another which is ideal for my purpose!  Thank you for getting me back on track, and for your patience!

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

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard