cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Heliooso
Helper I
Helper I

Dropdown filter gallery descending

Hello,

 

Is it possible to filter gallery through a dropdown selection with 2 options "Price" and "Quantity" so for example when I select Price from the dropdown the most expensive item would be shown at the top.

 

Right now I am having a sort button for Price and a search box for searching and it's all working. The items formula for gallery is:

SortByColumns(Filter(NameQuantityPriceTable,SearchBox.Text in Quantity&Name&Price),"Price",If(SortDecending, Ascending, Descending)) 

 

I would prefer the option to filter through a dropdown menu though. 

1 ACCEPTED SOLUTION

Accepted Solutions
Heliooso
Helper I
Helper I

Hey all, 

 

I've found a solution in another topic I made; Solved: Sort by dropdown descending - Power Platform Community (microsoft.com) 

 

Thank you all for your input on this matter. 👍

View solution in original post

8 REPLIES 8
Drrickryp
Super User
Super User

Hi @Heliooso 

You should be able to use a dropdown to help filter your table.  However, it would be helpful to see a screenshot of your NameQuantityPriceTable table. that you are filtering.  It sounds like an Inventory list. 

Heliooso
Helper I
Helper I

Hi @Drrickryp ,thank you for the quick reply. 🙂

 

Screenshot is attatched. Datasource is excel.

Drrickryp
Super User
Super User

Hi @Heliooso 

SortByColumns(
               If(
                   IsBlank(
                            SearchBox.Text
                     ),
                        Filter(
                                NameQuantityPriceTable,
                                Name=Dropdown1.Selected.Name
                          ),
                        Filter(
                                NameQuantityPriceTable,SearchBox.Text                                       
                                in Quantity&Name&Price
                         )
              ),"Price",If(
                            SortDecending, Ascending, Descending
                         )
) 

 

This formula give users the option of filtering the gallery by the SearchBox if something is entered into it and if it is blank, then the dropdown will filter the gallery. 

Heliooso
Helper I
Helper I

Hello again @Drrickryp 

 

How can I sort the items with the dropdown though, is it even possible I cant seem to find any information on it. 

I want the dropdown to have "Price" and "Quantity" when I select Quantity the items will be sorted in decending order, Can this be done with the dropdown ? I suppose the dropdown has to have "All" aswell.  

 

I made the formula simpler a bit so I could focus on the dropdown.

 

Heres the formula I'm using now: 

If(Dropdown1.Selected.Result = "All", NameQuantityPriceTable, Filter(NameQuantityPriceTable, Name = Dropdown1.Selected.Result))

 

Sorry if I explained it wrong before, I might have misunderstood Sort and Filter.

Drrickryp
Super User
Super User

Hi @Heliooso 

I will try to help you simplify this.  I prefer to use add a blank in the dropdown to leave the list unfiltered.

In the OnVisible property of the screen containing the gallery and dropdown put

 

ClearCollect(
              NQPT, NameQuantityPriceTable, {Result:""}
);// creates a collection with a column "Result" and a blank value
Collect(
        NQPT, Sort(
                      Distinct(
                                 NameQuantityPriceTable, Name
                      ), Result, Ascending
                )
) // Adds the sorted Names to the NQPT collection with a blank as the first value

 

This produces a single column collection called NQPT with the column name as Result to be used as the Items property of your dropdown so set the Items property of the dropdown to NQPT.

Then, set the Gallery Items property to 

 

Filter(NameQuantityPriceTable, Name = Dropdown1.Selected.Result)

 

If you want to sort your gallery by name and quantity, you can add a SortByColumns() function as follows

 

SortByColumns(
              Filter(
                      NameQuantityPriceTable, Name= Dropdown1.Selected.Result
               ),"Name", Ascending, "Quantity", Descending
)

 

 

 

 

Heliooso
Helper I
Helper I

Thank you @Drrickryp , I have learned a lot from this already. I added your formulas.

 

I made a new app from blank just for this purpose, attached screenshots. Is it possible to add Name, Quantity and Price to the dropdown list, so when I select price it will sort the items by price in a descending order ? I have not seen anyone done this before and I have searched everywhere. 🤔

Hi @Heliooso ,

 

You will need to expand the formula with a Switch function as follows:

Switch(Dropdown1.Selected.Result,
       "Name",
       SortByColumns(
                     NameQuantityPriceTable,
                     "Name",
                     Descending
       ),
       "Quantity",
       SortByColumns(
                     NameQuantityPriceTable,
                     "Quantity",
                     Descending
       ),
       "Price",
       SortByColumns(
                     NameQuantityPriceTable,
                     "Price",
                     Descending
       )
)

Please refer to the doc of Switch function:

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

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

Heliooso
Helper I
Helper I

Hey all, 

 

I've found a solution in another topic I made; Solved: Sort by dropdown descending - Power Platform Community (microsoft.com) 

 

Thank you all for your input on this matter. 👍

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Top Kudoed Authors
Users online (1,129)