cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Phineas
Post Prodigy
Post Prodigy

Cascading Combo Boxes

I have a Gallery that has three Combo Box that work together to deliver the intended data.

 

Currently Combo Box 2 and Combo Box 2 populate from the data set based on the choice in Combo Box 1.

 

Removing a choice from Combo Box 1 updates the content in Combo Box 2 and Combo Box 3.

 

However, removing/adding items in Combo Box 2 does not change the content of Combo Box 1 or Combo Box 3, nor does removing/adding an item to Combo Box 3 update/change the content of Combo Box 1 or Combo Box 2.

 

Is there a way to update the following to allow the above? Once an Item is chosen in Combo Box 1 changes to any of the three update all three?

 

Combo Box1

Items:

Sort(Distinct(CorporateDataCollection, Title), Result)

 

DefaultSelectedItems:
With({wCorporateData:Sort(CorporateDataCollection, ProcurementProfessional,Descending)},

Sort(Distinct(Filter(CorporateDataCollection, Title in CategoryCommodityCB_1.SelectedItems.Result),

ProcurementProfessional),Result))

 

Combo Box2

Items:

Sort(Distinct(CorporateDataCollection, PurchasingGroup), Result)

 

DefaultSelectedItems:
With({wCorporateData:Sort(CorporateDataCollection, PurchasingGroup, Descending)},

Sort(Distinct(Filter(CorporateDataCollection, Title in CategoryCommodityCB_1.SelectedItems),PurchasingGroup),Result))

 

Combo Box3

Items:

Sort(Distinct(CorporateDataCollection, ProcurementProfessional), Result)

 

DefaultSelectedItems:
With({wCorporateData:Sort(CorporateDataCollection, ProcurementProfessional, Descending)},

Sort(Distinct(Filter(DataCollection, Title in CategoryCommodityCB_1.SelectedItems.Result)

,ProcurementProfessional),Result))

 

Phineas_0-1650728955829.png

 

11 REPLIES 11
Verweij
Super User
Super User

In combobox you refer to the SelectedItems in Combobox 1. That’s why it’s updates when you change it. As far as I can understand from your functions, in combobox 1 and 3 you are not referring to some intro from Combobox 2. So what you are trying to achieve is not fully clear. 

 

If you just want to reset the comboboxes, you could use a Reset(comboboxName) function on the OnChange of Combobox 2. Not sure if this is what you are looking for though.

Let me try again from the view of the content of the Combo Boxes.

Combo Box 1 content is from the 'Location' column in the Collection. There are Location names. The user selects 'Boston' as the Location.

 

Combo Box 2 responds by populating 'Mary Smith', 'George Peters', 'Annie Young'

 

Combo Box 3 is auto-populated with 'English', 'Math', 'Gym'.

 

As currently configured if I add/remove and item from Combo Box 1, Combo Box 2 & 3 update accordingly (but based solely off of the content of Combo Box 1.

 

If, however, the user chooses to add/remove an item from Combo Box 2, nothing happens to Combo Box 1 or 3.

 

I know why nothing happens; the action is triggered by the content of Combo Box 1.

 

My question, is there any way to write the three formulas so that all Combo Boxes respond accordingly no matter which one has content added/removed?

 

If I change 3, 2 & 1 update. If I change 2, 3 & 1 update? Right now ONLY if I change I does 2 & 3 update.

Drrickryp
Super User
Super User

@Phineas 

This is not a cascading combobox problem. What you have is co-dependent comboboxes.  In the OnChange event of each combobox create a context variable for it's selected items. The example below uses a sales collection, sls, with columns for region, country and items. A variable is created in the OnChange property of its combobox and is used in the items property of the other comboboxes as shown beneath the combobox.

UpdateContext({rgns:Self.SelectedItems}),UpdateContext({cntrys:Self.SelectedItems}),UpdateContext({itms:Self.SelectedItems}) respectively.  Then the Items property of each combobox has to account for each possible condition. In the example below,  each combobox filters for the other two as well as if neither or both of the other comboboxes have selected items. 

!1.jpg

So, I should leave everything the way it is and add the three formulas you have provided to the 'OnChange' property of each Combo Box, yes?

Drrickryp
Super User
Super User

@Phineas 

 Create the variables with the formulas above the combobox and look at the formulas under each combobox and fix yours accordingly.

Do I ALSO delete the contents of all the Combo Box 'DefaultSelectedItems' property fields; which currently contains the working filter?

 

Also, since Combo Box already changes the contents of 2 and 3 do I need the 'OnChange' for the first Combo Box? Or, I'm I updating it ALSO - as referenced above?

I've updated all the formulas. No errors and I am getting auto-population from 1 to 2 & 3. All seems to work as my original formulas.

 

Meaning, nothing happens to 1 and 3 when I change 2, or nothing happens to 1 & 2 when I change 3.

 

I created the variable and placed them in the OnChange of each Combo Box.

 

I placed the updated formulas in each of the 'DefaultSelectedItems' properties of the Combo Boxes.

 

I have Sort(Distinct(Collection, [columntitle]), Result) in the 'Items' property of the Combo Boxes, as the intent is to allow for search and change of content, which would trigger the update and change in the other two Combo boxes - which is not happening at this point.

Drrickryp
Super User
Super User

@Phineas 

Hit the reset button and change the order that you pick them. 

Okay, Mr. Fancy pants (no disrespect intended), is there not a way to include the reset in the formula of the 'OnChange' variables?

 

Is it necessary to add a step to the user experience?

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (4,902)