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 Apps
Answered

Sort the gallery

(0) ShareShare
ReportReport
Posted on by

Hi 

I have the data displayed using the gallery, now I would like to add the column sorting
I started by alphabetically sorting through the description of the idea and the date it was created in ascending and descending order.
The way it works is I put a button that I click and it sorts in descending order, I click a second time and it sorts in ascending order.

Below you can see the code I'm using, currently it only sorts the date and the description of the idea doesn't want to sort, I don't know why, of course I'd like to add more such sorts

 

this code I have in Item on gallery 

SortByColumns(
    Sort(
        ThisItem.Data;
        'Idea description';
        If(varSortDescending1; SortOrder.Descending; SortOrder.Ascending)
    );
    "Created";
    If(varSortCreated1; SortOrder.Descending; SortOrder.Ascending)
)
 
This code is from button on select for idea description sorting
If(varSortDescending1; Set(varSortDescending1;false); Set(varSortDescending1; true))
 
This code is from button on select for Created sorting
If(varSortCreated1; Set(varSortCreated1 ;false); Set(varSortCreated1 ; true))
 
I have created variables on OnStart in applications
Set(varSortDescending1;true) And Set(varSortCreated1;true)
 
Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @AndrejPavlik18 ,

     

    Please try:

    SortByColumns(
     ThisItem.Data;
     "Idea description";
     If(varSortDescending1; SortOrder.Descending; SortOrder.Ascending);
     "Created";
     If(varSortCreated1; SortOrder.Descending; SortOrder.Ascending)
    )

     

    Best Regards,

    Bof

  • gilsSS Profile Picture
    on at

    Hi, you can read the documentation for it

    this is the link 

    https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-sort

  • AndrejPavlik18 Profile Picture
    on at

    Hi 

    Thanks it´s working 🙂

     

    BR 

    Andrej 

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 516

#2
WarrenBelz Profile Picture

WarrenBelz 428 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 292

Last 30 days Overall leaderboard