cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sajarac
Level 8

Sorting a Gallery based on two (2) Conditions

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Sorting a Gallery based on two (2) Conditions

@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."

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Sorting a Gallery based on two (2) Conditions

@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
Level 8

Re: Sorting a Gallery based on two (2) Conditions

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?

Super User
Super User

Re: Sorting a Gallery based on two (2) Conditions

Missed the filter out:

 

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

 

 

Super User
Super User

Re: Sorting a Gallery based on two (2) Conditions

@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
Level 8

Re: Sorting a Gallery based on two (2) Conditions

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,

 

Highlighted
Super User
Super User

Re: Sorting a Gallery based on two (2) Conditions

@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."

View solution in original post

sajarac
Level 8

Re: Sorting a Gallery based on two (2) Conditions

Fantastic!!!

Thank you so much!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,897)