cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
cmalm Helper I
Helper I

Filter Second Combo Box with Selection in First Combo Box

I have 2 tables (lots_table and sublots_table) that are related through a primary and foreign key respectively. Both combo boxes are set to single selection. The 1st combo box's (cmbLots) Items property is "lots_table". The DisplayFields property of the 1st combo box (cmbLots) is a text field in the lots_table.

 

The 2nd combo box's Items property is:

Filter(sublots_table, lots_table_fk.Id = cmbLots.Selected.ID)

 

The 2nd combo box's (cmbSublots) DisplayFields property is a text field in the sublots_table.

 

Currently there are no errors in the code and combo box 2 (cmbSublots) does display the text field referenced. However, combo box 2 (cmbSublots) does not filter based on the selection in combo box 1 (cmbLots). I need this filter to work.

 

Please help! Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
cmalm Helper I
Helper I

Re: Filter Second Combo Box with Selection in First Combo Box

I figured it out. Little embarrassing. Code below.

 

Filter(sublots_table, lots_table_fk = cmbLots.Selected.lots_table_pk)

 

Could have swore I tried this initially. Guess not. Thanks for the help you guys.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Filter Second Combo Box with Selection in First Combo Box

Hi @cmalm 

If you used a dropdown control and set its items property to 

Filter(sublots_table, lots_table_fk.Id = cmbLots.Selected.ID)

would it work? I did find a reference to filtering comboboxes but haven't tried it.  https://powerusers.microsoft.com/t5/Building-Power-Apps/Filtering-one-combo-box-items-based-on-anoth... 

Community Support
Community Support

Re: Filter Second Combo Box with Selection in First Combo Box

Hi @cmalm,

 

If my understanding is correct, the data source is SQL Server and the lots_table_fk is the column in sublots_table that is the foreign key of lots_table, right?

So please try this code:

Filter(sublots_table, lots_table_fk = cmbLots.Selected.ID)

 Hope this helps.

Sik

cmalm Helper I
Helper I

Re: Filter Second Combo Box with Selection in First Combo Box

I figured it out. Little embarrassing. Code below.

 

Filter(sublots_table, lots_table_fk = cmbLots.Selected.lots_table_pk)

 

Could have swore I tried this initially. Guess not. Thanks for the help you guys.

View solution in original post

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,561)