cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to filter using combobox

Hello, 

 

I am working on a "Book a Room" app. I am trying to filter a gallery called "RoomsGallery" connected to a list called "AllRooms" using a combobox called "LocationBox." The building names in the gallery only contain an abbreviation of the city's name. I want to make it so that when I select a certain building location, it will filter the gallery based on that. For example if I select "Washington, DC" I would want the gallery to show only the rooms that start with "DC"

 

How do I go about doing that?

3 REPLIES 3
mr-dang
Level 10

Re: How to filter using combobox

Hi @Anonymous,

It sounds like you want to use a ComboBox to filter a Gallery. 

 

Given your requirements, the solution to this is likely something you do within the table you hook up to the ComboBox. You will want to provide the full name and abbreviation of the location in your table.

 

IdFullNameAbbreviation
1Washington, DCDC
2CaliforniaCA
3WashingtonWA

 

The ComboBox allows you to show the column you want--in your case you want to show the FullName as the DisplayField. But what you select in the ComboBox is a record; this means that selecting California is really selecting all the information in the record:

{Id: 1, FullName: "California", Abbreviation: "CA"}

So instead of attempting to filter your gallery based on the full name of the location, you filter it based on its corresponding abbreviation:

Filter(datasource, location=ComboBox.Selected.Abbreviation)

This means, "Filter the datasource where the location is equal to the abbreviation that is selected from the ComboBox."

 

Let me know how it goes.

 

Mr. Dang

________

Microsoft Employee
@8bitclassroom
Community Support Team
Community Support Team

Re: How to filter using combobox

Hi @Anonymous,

 

Like @mr-dang suggested, when you select one value from combo box, you are selecting a record. 

 

I want to know what are the items in your ComboBox? Is "Washington, DC" 2 items that already selected or is it one? If you only have one item selected each time to filter the gallery, then you do not need to use a combo box, you could just use a dropdown control.

 

If what you need is truly a combo box, and you want to filter the gallery according to multiple items selected in combo box, then in addition to @mr-dang's suggestion, the formula of filtering with combo box should be something like:

Filter(
datasource,
First(LastN(ComboBox1.SelectedItems,1)).Abbreviation in location && First(LastN(ComboBox1.SelectedItems,2)).Abbreviation in location && First(LastN(ComboBox1.SelectedItems,3)).Abbreviation in location && ... )

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: How to filter using combobox

Error Msg.PNGLocation Box.PNGTable.PNGThere is a built in variable called "Location." However, I get an invalid arguement message when I use it. Am I supposed to create a new variable or is there something wrong with my code pictured?

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,849)