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.
Solved! Go to Solution.
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. 👍
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.
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.
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.
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
)
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.
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
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. 👍
User | Count |
---|---|
260 | |
110 | |
89 | |
52 | |
44 |