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

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,989 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,271 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,989 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,271 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,989 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,271 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

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard