cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CharyKid
Level: Power Up

How to load a ComboBox' Items based on selected item of another ComboBox in PowerApps

1. Load driver combobox items first

Example: Distinct('[dbo].[Products]',ProductGroup)

 

2. Every time the Driver Combobox selected item changes the dependant combobox items need to refresh.

(a) So create a dataset with only 2 columns out of many columns of source table with ShowColumns()

(b) Then filter the dataset of ProductGroup and ProductName by selected ProductGroup Filter()

(c) Then for each productgroup you may see multiple similar products so make it distinct by Distinct()

(d) Then store the unique ProductsNames into a collection of items in OnChange Event of the Driver ComboBox ClearCollect(). Clear Collect function clears and reloads the collection every time it run

Example: ClearCollect(clxProductNames, Distinct(Filter(ShowColumns( '[dbo].[Products]',"ProductGroup","ProductName"),ProductGroup=cbProductGroup.Selected.Result),ProductName))

 

3. Now copy the same code in 2 in to Onselect event of the dependant combobox in case (optional)

 

4. Load the Collection into Items by setting property of Dependant Combobox Items : clxProductNames

 

5. Now set the selected value of dependant combobox's selected item to first value of the list by defaultselectedItems : First(clxProductNames.Result)   as clxProductNames.Result returns a collection of values which cant be assigned

3 REPLIES 3
CharyKid
Level: Power Up

Re: How to load a ComboBox' Items based on selected item of another ComboBox in PowerApps

The above data source is SQL server table

Super User
Super User

Re: How to load a ComboBox' Items based on selected item of another ComboBox in PowerApps

Hi Kid, I couldn't tell from your post if you are giving advice or asking for help. It sounds like you want to create cascading comboboxes.
Super User
Super User

Re: How to load a ComboBox' Items based on selected item of another ComboBox in PowerApps

Working with Cascading comboboxes will create delegation issues and In general, it is better to create a new table and use that to load the combobox than to use the underlying table to create the Items. By having a separate table you will be much better able to add or remove items. https://powerusers.microsoft.com/t5/General-Discussion/Cascading-Combobox-Not-possible/td-p/108240 has a good discussion of the issues you are facing or will face.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 197 members 4,024 guests
Please welcome our newest community members: