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

Sorting a gallery

(0) ShareShare
ReportReport
Posted on by 440

Hi everyone, again my brain has frozen on something which should be fairly rudimentary. I have created nothing more than an address book which has a Sharepoint List in the background. I have created a screen where the user can search for a contact, or simply scroll down. To make the gallery the focus of the search function I have assigned the following formula to the Gallery's Items property. 

Search('Contractor List',TextInput1.Text,"Title")
 
My issue is that the gallery is listed in the order in which contacts were added. I wanted to add an icon to sort the gallery. I keep messing up the syntax and nothing shows anymore unless I return to the original formula as above.

 

Categories:
I have the same question (0)
  • Verified answer
    CU05080617-0 Profile Picture
    136 on at

    Hello there.

    I good detailed video from Reza about sorting a gallery that helped me in a similar case.

    https://www.youtube.com/watch?v=6KlI1iZ_KD0&t=1091s&ab_channel=RezaDorrani

    Hope this helps.

    Nick

  • nshaw75 Profile Picture
    440 on at

    Thanks Nick, I must say Reza is a great source of info on the Power platforms, helped me out a lot. I have a feeling I have gone formula blind and am either putting a comma or semicolon in the wrong place. 

  • nshaw75 Profile Picture
    440 on at

    Hi Nick I have followed the video by  Reza and am still struggling. As you can see in the two attached screenshots, he does explain exactly what I am after. However.when I copy him a) He uses the formula with the wording simply as ",Descending)" Although when I use the same syntax it does not work, but prompts ",SortOrder.Descending)". Also whenever I use either it doesn't work 😕 

     

    nshaw75_0-1710933004244.jpegnshaw75_1-1710933021247.png

     

     

  • CU05080617-0 Profile Picture
    136 on at

    Hi.

    I can not see your variables. Please provide the error if any. I follow the exact same steps from Reza and I figured it out correctly.
    In arrow, for ID column, I wrote: (same for Title, and Number columns)

    Set(varSortColumn,"ID");

    Set(varSortDirection,
    If(
    varSortDirection = SortOrder.Ascending,
    SortOrder.Descending,
    SortOrder.Ascending
    )
    )

    For my gallery:
    SortByColumns(
    Filter(
    Test,
    StartsWith(Title,TextInput3.Text)
    ),
    varSortColumn,
    varSortDirection)

    And please don't forget on start variables:
    Set(varSortColumn,"ID");Set(varSortDirection,SortOrder.Descending)

    *Test is my data source sharepoint list.

    ezgif-7-3424d3e13c.gif




  • nshaw75 Profile Picture
    440 on at
    Thanks again for looking at this.
    I have already seen a glaringly obvious error, as I have been using the Search box label and not TextInput . And I am also questioning why I have 'Title' in the formula 😬
     
    SortByColumns(Filter('Contractor List',StartsWith(Title,Label3.Text)),"Title",SortOrder.Ascending
     
    I have a SP list called 'Contractor List', I use a gallery called 'Gallery1' which has 2 sets of Data Labels. 1 is 'Company Name' which is the variable I want to sort by and another which is 'Category'. This is based on a choice column in the Sharepoint list and I know that this will be awkward so not really worried too much about that. 

    I have a Search box which returns TextInput 1. This is the error I have been getting  meanwhile I will try and clear my head and try again 😄 
    nshaw75_0-1710950649318.png

     

  • nshaw75 Profile Picture
    440 on at

    I have had a moment of clarity and I have got it working. I think that I was getting blind to the obvious mitsakes I was creating.  When I stare at lines of syntax they eventually all look the same 😞 here is the formula now which is working.  

    SortByColumns(Filter('Contractor List',StartsWith(Title,TextInput1.Text)),"Title",SortOrder.Ascending)



    Thanks again @NickFot for the help and guidance

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 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard