cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShadowTech
Post Prodigy
Post Prodigy

Create multiple sorting icons for single gallery

Hello,

 

I have added an icon for sorting a gallery by column "SortByColumns" but want to add another for another column but having trouble with the formula. Below is what I have so far. How would I add the second "SortByColumns" for second icon?

 

I would like to add another icon for "SortByColumns" for "Customer".

 

SortByColumns(Filter(Search(LIST01, SearchBox.Text, "E_x002d_mail", "Customer", "LISTRMA_x0023_", "Contact"), If(Dropdown1.Selected.Value = "All", true, Status.Value = Dropdown1.Selected.Value), If(Dropdown2.Selected.Value = "All", true, Branch.Value = Dropdown2.Selected.Value)), "LISTRMA_x0023_", If(SortDescending1, Descending, Ascending))

 

Thanks in advance.

7 REPLIES 7
WarrenBelz
Super User III
Super User III

Hi @ShadowTech ,

If you set the second icon to toggle

UpdateContext({SortDescending2:!SortDescending2})

you could do this

SortByColumns(
   Filter(
      Search(
         LIST01, 
         SearchBox.Text, 
         "E_x002d_mail", 
         "Customer", 
         "LISTRMA_x0023_", 
         "Contact"
      ), 
      If(
         Dropdown1.Selected.Value = "All", 
         true, 
         Status.Value = Dropdown1.Selected.Value
      ), 
      If(
         Dropdown2.Selected.Value = "All", 
         true, 
         Branch.Value = Dropdown2.Selected.Value
      )
   ), 
   "LISTRMA_x0023_", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   ),
   "Customer",
   If(
      SortDescending2, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

@WarrenBelz 

 

Tried that same implementation but for some reason the second sort button does not execute that function. Nothing happens when clicking the second sort button. Just the first sort button works.

 

Any ideas?

 

Thanks.

Hi @ShadowTech ,

Strange, but I have not tried that before, so try this

Sort(
   Sort(
      Filter(
         Search(
            LIST01, 
            SearchBox.Text, 
            "E_x002d_mail", 
            "Customer", 
            "LISTRMA_x0023_", 
            "Contact"
         ), 
         If(
            Dropdown1.Selected.Value = "All", 
            true, 
            Status.Value = Dropdown1.Selected.Value
         ), 
         If(
            Dropdown2.Selected.Value = "All", 
            true, 
            Branch.Value = Dropdown2.Selected.Value
         )
      ), 
      LISTRMA_x0023_, 
      If(
         SortDescending1, 
         Descending, 
         Ascending
      )
   ),
   Customer,
   If(
      SortDescending2, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz Yeah that doesn't work. Using "SortByColumns(SortByColumns(" doesn't work either.

@ShadowTech ,

The syntax structure should be valid - what do you mean by "it does not work" - does the code produce an error?

Also note that this will sort by LISTRMA_x0023_ and then Customer - do want to sort by one or the other ? If so you need another structure with a value (say radio control) with Items ["Customer", "ListRMA"] and would look something like this (and you can go with a single sort button).

Sort(
   Filter(
      Search(
         LIST01, 
         SearchBox.Text, 
         "E_x002d_mail", 
         "Customer", 
         "LISTRMA_x0023_", 
         "Contact"
      ), 
      If(
         Dropdown1.Selected.Value = "All", 
         true, 
         Status.Value = Dropdown1.Selected.Value
      ) &&
      If(
         Dropdown2.Selected.Value = "All", 
         true, 
         Branch.Value = Dropdown2.Selected.Value
      )
    ), 
   If(
      YourRadio.Selected.Value="Customer",
      Customer, 
      LISTRMA_x0023_
   ), 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

 Please note all of this is free-typed, so watch commas and brackets etc.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @ShadowTech ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

vladimir84
Helper V
Helper V

I have the same issue, and I also tried multiple SortByColumns and Sort

They should work regardless, because they are distinct commands.

You sort once, and then resort again.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,550)