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?

12 REPLIES 12
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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,646)