Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • AndrejPavlik18 Profile Picture
    on at
    Re: Sort the gallery

    Hi 

    Thanks it´s working 🙂

     

    BR 

    Andrej 

  • gilsSS Profile Picture
    on at
    Re: Sort the gallery

    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

  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: Sort the gallery

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard