cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tommysantos14
Frequent Visitor

How to Filter a Gallery using a Combo Box

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?

11 REPLIES 11
CarlosFigueira
Power Apps
Power Apps

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:

ComboBox.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

And this is my Gallery's formula on Items. The Inventory data source is a SharePoint List, and ItemType is a Choice column. 

GalleryFilter.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

And the resulting error:
Formula Error.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

tommysantos14
Frequent Visitor

Any thoughts, this is holding up our project. Thank you for your help!

Hi,

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

SelectedItems.ID

 

Filter(Products, Department.Id in ComboboxDepartments.SelectedItems.ID)

 

At least this works on my end, my data is from SharepointLists.

I am having the same problem and haven't seen a clear answer anywhere on this either. Anybody have any answers for this issue?

Anonymous
Not applicable

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.

Example:

Filter(DataSource, ColumnName in ComboBox.SelectedItems.ColumnName)
Anonymous
Not applicable

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.

Hero, after lots of tinkering and frustration... this was exactly the thing I was looking for. 

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (3,190)