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

2 Combobox to feed 3rd Combobox Multi-Level Cascading

Hi Everyone, 

 

I am trying to build an app. Where I want 2 combobox to feed 3rd combobox. My data has Continent, Country and Factory. 

 

I want the first box to have continents, 2nd to have countries and based on the options selected in the first two boxes factories should appear in the 3rd combobox. For example, if the continent selected are N.America and Asia, countries like USA, China, India, Japan should appear. Then if China and USA are chosen all the factories in these countries should appear in the 3rd Combobox. 

 

Please help me with this as I have been struggling with it since past 1 week. 

 

Thanks in advance,

Shreyans 

1 ACCEPTED SOLUTION

Accepted Solutions
Alex_10
Super User
Super User

@Shreyans15 

 

not an elegant solution, but works:

 

combobox1 is for region

combobox2 - business units

combobox3 - plants

 

 

add a button.

button.OnSelect = 

ClearCollect(colCountries,
{'Region': "Asia", 'Business Unit': "BE", 'Plant Name': "FED Plant" },
{'Region': "N.America", 'Business Unit': "SE", 'Plant Name': "COM Plant" },
{'Region': "Mexico", 'Business Unit': "TE", 'Plant Name': "BI Plant" },
{'Region': "EMEA", 'Business Unit': "LE", 'Plant Name': "SU Plant" },
{'Region': "S.America", 'Business Unit': "BE", 'Plant Name': "SI Plant" },
{'Region': "Australia", 'Business Unit': "TE", 'Plant Name': "SIM Plant" },
{'Region': "EMEA", 'Business Unit': "TE", 'Plant Name': "SN Plant" },
{'Region': "S.America", 'Business Unit': "LE", 'Plant Name': "MU Plant" },
{'Region': "Australia", 'Business Unit': "BE", 'Plant Name': "RE Plant" }
)

 

 

combobox1.Items = Distinct(colCountries, Region)

 

combobox1.OnChange = 

Reset(ComboBox2);
Reset(ComboBox3);
Clear(temp1);
ForAll(Self.SelectedItems As ThisRegion, Collect(temp1, Filter(colCountries, Region = ThisRegion.Result)))

 

 

combobox1.Fields.PrimaryText = Result // on the right settings panel

 

 

combobox2.Items = Distinct(temp1, 'Business Unit')

 

combobox2.OnChange = 

Reset(ComboBox3);
Clear(temp2);
ForAll(Self.SelectedItems As ThisBusinessUnit, Collect(temp2, Filter(temp1, 'Business Unit' = ThisBusinessUnit.Result)));

 

combobox2.Fields.PrimaryText = Result // on the right settings panel

 

 

combobox3.Items = temp2

 

combobox3.Fields.PrimaryText = Plant Name // on the right settings panel

 

 

View solution in original post

9 REPLIES 9
Alex_10
Super User
Super User

@Shreyans15 

how many factories do you have in total? and what is the data structure of your data?

Hi Alex, 

 

I have around 70-80 factories in my data. 

 

 

1.Region    2. Business Unit    3.Plant Name 

Asia BEFED Plant
N.AmericaSECOM Plant
MexicoTEBI Plant 
EMEA LESU Plant 
S.America BESI Plant
AustraliaTESIM Plant 
EMEA TESN Plant 
S.America LEMU Plant 
AustraliaBE

RE Plant

This is a glimpse of my data. I want the customer to be able to select multiple region from Combox 1. Based on that selection the Business Units available in those region should pop up in the Combox2 which will allow mutiple choice too. Then third combox should have options based on the selections made in combox 1 and 2. 

 

Please help as because of this issue my almost complete project is on hold since past 1 week. 

Alex_10
Super User
Super User

@Shreyans15 

Plant Names are always unique? (never repeat in the list)

Yes plant names are always unique they don't repeat.

 

Alex_10
Super User
Super User

@Shreyans15 

 

not an elegant solution, but works:

 

combobox1 is for region

combobox2 - business units

combobox3 - plants

 

 

add a button.

button.OnSelect = 

ClearCollect(colCountries,
{'Region': "Asia", 'Business Unit': "BE", 'Plant Name': "FED Plant" },
{'Region': "N.America", 'Business Unit': "SE", 'Plant Name': "COM Plant" },
{'Region': "Mexico", 'Business Unit': "TE", 'Plant Name': "BI Plant" },
{'Region': "EMEA", 'Business Unit': "LE", 'Plant Name': "SU Plant" },
{'Region': "S.America", 'Business Unit': "BE", 'Plant Name': "SI Plant" },
{'Region': "Australia", 'Business Unit': "TE", 'Plant Name': "SIM Plant" },
{'Region': "EMEA", 'Business Unit': "TE", 'Plant Name': "SN Plant" },
{'Region': "S.America", 'Business Unit': "LE", 'Plant Name': "MU Plant" },
{'Region': "Australia", 'Business Unit': "BE", 'Plant Name': "RE Plant" }
)

 

 

combobox1.Items = Distinct(colCountries, Region)

 

combobox1.OnChange = 

Reset(ComboBox2);
Reset(ComboBox3);
Clear(temp1);
ForAll(Self.SelectedItems As ThisRegion, Collect(temp1, Filter(colCountries, Region = ThisRegion.Result)))

 

 

combobox1.Fields.PrimaryText = Result // on the right settings panel

 

 

combobox2.Items = Distinct(temp1, 'Business Unit')

 

combobox2.OnChange = 

Reset(ComboBox3);
Clear(temp2);
ForAll(Self.SelectedItems As ThisBusinessUnit, Collect(temp2, Filter(temp1, 'Business Unit' = ThisBusinessUnit.Result)));

 

combobox2.Fields.PrimaryText = Result // on the right settings panel

 

 

combobox3.Items = temp2

 

combobox3.Fields.PrimaryText = Plant Name // on the right settings panel

 

 

View solution in original post

Thankyou for the help Alex. I have some questions. Why did you add the button in the first step? Also, I have uploaded my data on the sharepoint list still I have to run ClearCollect? Typing that function can be really hard as I have more than 80plants. 

Alex_10
Super User
Super User

you can try to do it without a button:

combobox1.Items = Distinct(yourSP_list, Region)

 

combobox1.OnChange = 

Reset(ComboBox2);
Reset(ComboBox3);
Clear(temp1);
ForAll(Self.SelectedItems As ThisRegion, Collect(temp1, Filter(yourSP_list, Region = ThisRegion.Result)))

 

 

combobox1.Fields.PrimaryText = Result // on the right settings panel

 

code for other comboboxes is the same

Thankyou will try it and get back to you. 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,632)