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 Platform Community / Forums / Power Apps / Sorting a Gallery base...
Power Apps
Answered

Sorting a Gallery based on two (2) Conditions

(0) ShareShare
ReportReport
Posted on by 3,284

Morning,

 

Quick question here?

 

How can I sort my gallery items "Form a Share Point List" based on two conditions? I would like to have the items sorted first by Title "Single Line of Text" and then by ItemID "Number"

 

Thank in advance for any response.

 

Regards

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @sajarac 

    Put this code in the Items property of your Gallery

     

    SortByColumns(your_datasource_name,"Title",Ascending,"ID",Ascending)

     

    Link to SORTBYCOLUMNS Documentation

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-sort

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Sajarac Profile Picture
    3,284 on at

    Thank you very much, Almost done. I also have a condition for the gallery.

     

    I have the gallery sorted based on the value of a dropdown

     

    SortByColumns(LIPDatabase,CustomerID=Value(Label12.Text),"Title",Ascending,"ItemID",Ascending)

     

    I had this formula before and it was working fine but only sorting based on title

     

    Sort(Filter(LIPDatabase,CustomerID=Value(Label12.Text)),Title,Descending)

     

    Any idea?

  • Delid4ve Profile Picture
    795 on at

    Missed the filter out:

     

    SortByColumns(Filter(LIPDatabase,CustomerID=Value(Label12.Text)),"Title",Ascending,"ItemID",Ascending)

     

     

  • mdevaney Profile Picture
    29,991 Moderator on at

    @sajarac 

    Did you mean sorted by CustomerID or did you mean filtered?  Please clarify.

     

    SortByColumns(
     Filter(
     LIPDatabase,
     CustomerID=Value(Label12.Text)
     ),
     "Title",Ascending,
     "ItemID",Ascending
    )

     

  • Sajarac Profile Picture
    3,284 on at

    Sorry, let me try to explain properly:

     

    I have a dropdown "ComboBox3" = SortByColumns(LIPCustomers,"Title",Ascending)

    I have a label "Label12" = LookUp(LIPCustomers,Title=ComboBox3.Selected.Title,ID)

    My Gallery Itesm : Sort(Filter(LIPDatabase,CustomerID=Value(Label12.Text)),Title,Descending)

     

    And I would like to have the items in my gallery sorted first By Title then by ItemID

     

    Regards,

     

  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @sajarac 

    Sort(Sort(Filter(LIPDatabase,CustomerID=Value(Label12.Text)),Title,Descending),ItemID,Ascending)

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Sajarac Profile Picture
    3,284 on at

    Fantastic!!!

    Thank you so much!

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 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard