cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GaryHounslow
Helper III
Helper III

Filter Combobox based on another combobox

Good morning,

 

I am struggling a bit trying to filter a Combobox based on another Combobox, here is my scenario:

 

Combobox 1: Based on a local collection, this a multi select field

Combobox 2: Can be either based on  a local collection or can have its fields manually populated, I dont mind which as it is manually patched to a Sharepoint list anyway, this is also a multi select field

 

I would like Combobox 2 to only show relevant options based on what is selected in Combobox 1 as follows:

 

Combobox 1 selection: Early Years PVI Settings - Combobox2 to display: EYFS

Combobox 1 selection:  Primary (including EYFS) - Combobox to display: EYFS, KS1 and KS2 (3 fields)

Combobox 1 selection:  Secondary (including Post-16) - Combobox to display: KS3, KS4 and KS5

Combobox 1 selection:  FE/Sixth-Form Colleges  - Combobox to display: KS5

 

As both of these Comboboxes are multi select I need to ensure that Combobox 2 has all of the relevant options available based on Combobox1.

 

Any help much appreciated.

 

Many thanks

Gary

6 REPLIES 6
BCLS776
Super User
Super User

Gary, if this is a very static relationship with few chances of a change, consider hardcoding the Items for ComboBox2 using a Switch() based on the selection of ComboBox1. It's not elegant, but it can accomplish what you are after.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Thanks for the reply!

I've never used that command before, could you possibly give me a small example of the layout of that please?

It would look something like this in the Items property of the second combobox:

Switch(Combobox1.Selected.Value,
    "Early Years PVI Settings",["EYFS"],
    "Primary (including EYFS)",["EYFS","KS1","KS2"],
    "Secondary (including Post-16)",["KS3","KS4","KS5"],
    "FE/Sixth-Form Colleges",["KS5"]
)

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Thanks for this, however, it doesnt like the first line, presumably because first combobox is multi select?

Error I get is "Invalid number of arguments: received 1, expected 3 or more".

I tried .selected.value, .selecteditems and also .selecteditems.title with same error

Any ideas?

 

Edit, bracket was in wrong place.  Actual error is now:

The function switch has some invalid arguments.  Invalid arguments type (Text).  Expecting a Record value instead


@GaryHounslow wrote:

Thanks for this, however, it doesnt like the first line, presumably because first combobox is multi select?

Error I get is "Invalid number of arguments: received 1, expected 3 or more".

I tried .selected.value, .selecteditems and also .selecteditems.title with same error

Any ideas?

 

Edit, bracket was in wrong place.  Actual error is now:

The function switch has some invalid arguments.  Invalid arguments type (Text).  Expecting a Record value instead


Yes, a multi-select combobox significantly complicates the situation, since it creates a many-to-many relationship between the combobox1 and combobox2. Does the business logic require this?

 

One of the community members, Warren, has put together a good blog on the topic: check this out

 

Or, is there some other way to reduce this into a one-to-many relationship?

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
GaryHounslow
Helper III
Helper III

One to many isnt an option unfortunately, shame as i've already worked out how to do that way.

 

I looked at the guide you linked to, many thanks for that.  I couldnt figure out how to apply that to my scenario as it was working with a gallery in that example.

 

I've given up on this for now and said to our users I will look at doing that in v2 of the app.  Any other suggestions would still be very welcome 🙂

 

Thanks for the help !

 

Gary

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (1,355)