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
Super User
Super User

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
Super User
Super User

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
Super User
Super User

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 Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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