cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

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

Highlighted
Kudo Kingpin
Kudo Kingpin

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?

Highlighted
Impactful Individual
Impactful Individual

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

Missed the filter out:

 

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

 

 

Highlighted
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
)

 

Highlighted
Kudo Kingpin
Kudo Kingpin

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

Highlighted
Kudo Kingpin
Kudo Kingpin

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

Fantastic!!!

Thank you so much!

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,578)