cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Trish00
Microsoft
Microsoft

How to create Cascading Dropdowns

Hi all, 
 

I have 2 dropdowns with different values, one of the fields will be visible for users and the other one will be set to be invisible for management purposes.

 

Note* Both of the dropdowns come from two different tables which are stored in Data verse* There is no relationship between the two dropdowns or any similar columns. 

 

Dropdown 1 - R1, R2, R3

Dropdown2 - 1, 2, 3

 

How can I update Dropdown2 to automatically update when selection is made from Dropdown 1 based on mapping below.

 

R1 = 1

R2 = 2

R3 = 3

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Trish00,

Have you solved your problem?

Do you have Dropdown box?

Could you please tell me how you set the Items property of both two Dropdown boxes?

 

Here is the thing, you should set the Default property of the Dropdown box if you want to create cascading Dropdown boxes.

Note that you must set the Items property of the second Dropdown box with ["1","2","3"] or a table value from your Dataverse.

 

If you set both Dropdown boxes Items property using the TableName.FieldName, please check the following steps:

1). Set both Dropdown box Items property as below:

Table1.Field1
Table2.Field2

 2). Set the Default property of the second Dropdown box:

Switch(
    Dropdown7.Selected.Field1,
    "R1",
    "1",
    "R2",
    "2",
    "R3",
    "3"
)

vqiaqimsft_0-1654064498585.png

Ps: I write hard code for both Dropdown boxes, so I reference to the Value argument.

Best Regards,
Qi

View solution in original post

7 REPLIES 7
One
Resolver IV
Resolver IV

Hi @Trish00,

 

You can set the default property of the second dropdown to the following:

If(Dropdown1.Selected.Value = "R1",1,Dropdown1.Selected.Value = "R2",2,Dropdown1.Selected.Value = "R3",3)

------------------------------------------------------------------------------------------------------------------------------
Please click "Accept as Solution" if this post answered your question so that it is helpful for people having similar questions. If you found this post helpful smack that Thumbs up button! Thanks!

Hi this does not work; I have tried this before.

 

It gives me two of errors-  

Incompatible types for comparison and unexpected characters. 

 

I was able to set dropdown 2 to default by placing code on DefaultedSelectedItems

-

Switch(dropdown.selected.value,

"R1", {Value: "1"},

"R2",{Value:  "2"}

)

 

Although I'm having an issue with the dropdown that is being defaulted based upon those values to save back to the data source. It is only saving correctly when the dropdown is being selected manually, if anyone would know why that be great help.

One
Resolver IV
Resolver IV

Hello @Trish00

Ok I see, it definitely won't work if you are using combo boxes and not dropdown boxes. I was under the assumption you were using dropdown boxes like your original post said.

The switch function will work for what you are trying to do, however I would suggest using dropdown's instead of combo boxes. the combo box will look for a matching value in your data source to determine what to set as it's default value. whereas a dropdown box will work with the if statement I had posted previously to populate the second dropdown with a specific value when a selection is made in the first dropdown (Take a look at the 'Depends on' property of combo boxes for better example). so unless you need the functionality that comes with combo boxes (multiselect, searching, etc.) you would likely be better off using a dropdown since: 'there is no relationship between the two dropdowns or any similar columns'

I think there has been some misunderstanding, I haven't said I was using combo boxes, they are both dropdowns. 

 

I have also tried your solution however it didn't work it give me an error.

One
Resolver IV
Resolver IV

I agree there has been some misunderstanding. Dropdowns don't have a 'DefaultSelectedItems' property whereas combo boxes do. So now I am really confused as to how you are using dropdowns? screenshots provided are the properties of Dropdowns(First) and Combo Boxes(Second)

 

One_0-1653312541174.png

One_1-1653312554897.png

 

Hi @Trish00,

Have you solved your problem?

Do you have Dropdown box?

Could you please tell me how you set the Items property of both two Dropdown boxes?

 

Here is the thing, you should set the Default property of the Dropdown box if you want to create cascading Dropdown boxes.

Note that you must set the Items property of the second Dropdown box with ["1","2","3"] or a table value from your Dataverse.

 

If you set both Dropdown boxes Items property using the TableName.FieldName, please check the following steps:

1). Set both Dropdown box Items property as below:

Table1.Field1
Table2.Field2

 2). Set the Default property of the second Dropdown box:

Switch(
    Dropdown7.Selected.Field1,
    "R1",
    "1",
    "R2",
    "2",
    "R3",
    "3"
)

vqiaqimsft_0-1654064498585.png

Ps: I write hard code for both Dropdown boxes, so I reference to the Value argument.

Best Regards,
Qi

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,262)