web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard