Skip to main content

Notifications

Community site session details

Community site session details

Session Id : gBGxxORULs3AA1Tnc8dOZd
Power Apps - Building Power Apps
Unanswered

Gallery Search and Sort function

Like (0) ShareShare
ReportReport
Posted on 15 Jun 2021 13:52:44 by 776

Hi Experts,

 

I am using below formula 

 

SortByColumns(Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), "Title", If(SortDescending1, Descending, Ascending))

Now this is only working to sort on one column (title column)

 

How can i sort on other columns ?

 

AshishJaiswal_0-1623765113045.png

 

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on 15 Jun 2021 at 16:59:56
    Re: Gallery Search and Sort function

    unfortunately delegation will be there when using SortByColumns with variables. You can try this:

    running different sorting based on condition. Like keep the code on sorting buttons same. But change your gallery code to this:

    If(varColumn="Name",
    SortByColumns(
    Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), "Name", If(SortDescending1, Descending, Ascending)),

    if(varColumn="Availability",

    SortByColumns(Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), "Availability", If(SortDescending1, Descending, Ascending))))

     

    and so on.. So instead of usinf variable directly in sorting logic. You are running different sorting logics based on condition.

  • AshishJaiswal Profile Picture
    776 on 15 Jun 2021 at 15:19:37
    Re: Gallery Search and Sort function

    @zmansuri 

    Awesome this works but now I am running into a delegation issue of 500 items (My list has more than 3000 + items)

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on 15 Jun 2021 at 15:10:58
    Re: Gallery Search and Sort function

    Gallery:

    SortByColumns(Filter([@'datasourcesharepointlist'], StartsWith(Title,SearchBox.Text)), varColumn, If(SortDescending1, Descending, Ascending))

     

    Sorting Button Beside Name field:

    OnClick:

    UpdateContext({varSort :"Name"});
    UpdateContext({SortDescending1:!SortDescending1});

     

    Sorting Button Beside availability fields:

     

    OnClick:

    UpdateContext({varSort :"Availability "});
    UpdateContext({SortDescending1:!SortDescending1});

     

    In Short every time you click your sorting button beside field name. It will set the column name of that field in the variable varColumn

    So in your gallery code where right now you have written "Title", which is why it is sorted by title. It will be varColumn instead of Title. And varColumn will change with buttoin click

  • AshishJaiswal Profile Picture
    776 on 15 Jun 2021 at 15:01:55
    Re: Gallery Search and Sort function

    @zmansuri ,

     

    Hello,

     

    Thank you for replying to my post.

     

    Could you guide me how to write it. I am not a developer. I just learn from youtube and blogs  😃

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on 15 Jun 2021 at 13:54:30
    Re: Gallery Search and Sort function

    Instead of colum name in your gallery code use variable like "varColum"

    and onClick of your sorting arrow update the variable with columname using UpdateContext. So whichever sorting icon you click column name will be changed according

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

Overall leaderboard