
Announcements
I have gallery with SharePoint as the datasource. Outside the gallery I have a searchbox and a filter pane which includes 4 buttons named "Electrical Stuffs", "Home Appliances", "Drinks", "Perfumes"
The search functionality works fine without any issues. Below is the formula for Items property of Gallery
Filter(
DataSource,
(TextInput1.Text in 'Name' || TextInput1.Text in Description || TextInput1.Text in 'Unit Price' || TextInput1.Text in 'Category')
)
However when i try to add the filter buttons in above formula, gallery doesnt filter appropriately.
On each of the 4 buttons OnSelect, I used below formula
UpdateContext({varSelection:"Electrical Stuffs"})
UpdateContext({varSelection:"Home Appliances"})
UpdateContext({varSelection:"Drinks"})
UpdateContext({varSelection:"Perfumes"})
Amended Items property of gallery to below formula
Filter(
DataSource,
(TextInput1.Text in 'Name' || TextInput1.Text in Description || TextInput1.Text in 'Unit Price' || TextInput1.Text in 'Category')&&varSelection=Category
)
Any where I am going wrong?
The issue in your formula lies in the line where you compare varSelection with Category in the Filter function. Instead of varSelection=Category, you need to use varSelection = Category to properly compare the two values. Here's the corrected formula:
Filter(
DataSource,
(TextInput1.Text in 'Name' || TextInput1.Text in Description || TextInput1.Text in 'Unit Price' || TextInput1.Text in 'Category') && varSelection = Category
)
Ensure that the variable Category is the column name in your SharePoint list that stores the category value for each item.
Additionally, when you set the varSelection variable in the OnSelect property of the buttons, make sure you are using the correct category value. For example, if the button is for "Electrical Stuffs," the formula should be:
UpdateContext({varSelection: "Electrical Stuffs"})
Make sure you use the appropriate category values for each button.
By correcting these issues, the gallery should filter the items correctly based on both the search text and the selected category.