I have a basic Gallery on a screen and need to filter it based on the (possibly) multiple selections in the Combo Box control (not the drop-down).
I can't find a working solution for this. Any ideas?
You can use the in operator to check if one of the properties of the element in the collection that is being filtered was selected in the combobox, using the combobox SelectedItems property. For example, if you have a combobox with the following expression for the Items element:
["Produce", "Dairy", "Household Items", "Bakery", "Meats", "Pantry"]
And a data source (Products) with a column named "Department". If you want to show in a gallery the items for the selections, you can use this expression:
Filter(Products, Department in ComboboxDepartments.SelectedItems.Value)
Thanks, Carlos, but it's not working. I might be missing something obvious. Here are the details.
This is my Combo:
And this is my Gallery's formula on Items. The Inventory data source is a SharePoint List, and ItemType is a Choice column.
And the resulting error:
I was having the same issue as well, after tinkering with varoius ways of doing this,
found that the formula mentioned before works with just a bit of a minor change.
You have to add .Id to Departments and change the SelectedItems.Value to
Filter(Products, Department.Id in ComboboxDepartments.SelectedItems.ID)
At least this works on my end, my data is from SharepointLists.
I have data in SQL Server and am using this equivilant to allow multiple selections.
Filter(Products, Id in ComboboxDepartments.SelectedItems.ID)
In case anyone else experience this issue, the formula should list the column name after the SelectedItems.
Filter(DataSource, ColumnName in ComboBox.SelectedItems.ColumnName)
This worked great!
As a potential bonus for functionality, I set up my Gallery to change based on the search text until a user selected an item, then it switches to display only selected items:
If(CountRows(ComboBox.SelectedItems) = 0 || IsBlank(ComboBox.SelectedItems) , Search(DataSource, ComboBox.SearchText, ColumnName, Filter(DataSource, ColumnName in ComboBox.SelectedItems.ColumnName))
Edit: Had to add an 'Or' condition for initial loads where the ComboBox.SelectedItems is blank.
Check out new user group experience and if you are a leader please create your group
Next call is happening on April 21st at 8a PST.
May the fourth be with you, join us online!
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.