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

Switch If function

Hi I would like to cascade my dropdowns using conditions. Previously, I was able to do it with switch function. On my drpCountry dropdown, when I select a country, drpAvailable will show "No" automatically. Now, I added all the list of countries on my SharePoint list. All countries availability (drpAvailable) except for US is automatically (DefaultSelectedItems) set to No. When I select US in drpCountry, I should still be able to modify the drpAvailable to Yes or No.

 

Below is the code I've used before using the switch function

 

 

Switch(
    drpCountry.Selected.Value,
    "GB",
    {Value: "No"},
    "AU",
    {Value: "No"},
    "CA",
    {Value: "No"},
    "SA",
    {Value: "No"},
    "UAE",
    {Value: "No"}
)

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @biancadevera :

Could you please tell me:

What do these two sentences mean?

All countries availability (drpAvailable) except for US is automatically (DefaultSelectedItems) set to No. When I select US in drpCountry, I should still be able to modify the drpAvailable to Yes or No.

If you want the default option of this combo box to be "No" when the user selects "US", then the formula can be written like this:

 

Switch(
    drpCountry.Selected.Value,
    "GB",
    {Value: "No"},
    "AU",
    {Value: "No"},
    "CA",
    {Value: "No"},
    "SA",
    {Value: "No"},
    "UAE",
    {Value: "No"},
    {Value: "No"}
)

 

If you want the default option of this combo box to be "No" only when the user selects "US", and the formula is "Yes" when the user selects other values, the formula can be written like this:

Switch(
    drpCountry.Selected.Value,
    "US",
    {Value: "No"},
    {Value: "Yes"}
)​

Best Regards,

Bof

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @biancadevera :

Could you please tell me:

What do these two sentences mean?

All countries availability (drpAvailable) except for US is automatically (DefaultSelectedItems) set to No. When I select US in drpCountry, I should still be able to modify the drpAvailable to Yes or No.

If you want the default option of this combo box to be "No" when the user selects "US", then the formula can be written like this:

 

Switch(
    drpCountry.Selected.Value,
    "GB",
    {Value: "No"},
    "AU",
    {Value: "No"},
    "CA",
    {Value: "No"},
    "SA",
    {Value: "No"},
    "UAE",
    {Value: "No"},
    {Value: "No"}
)

 

If you want the default option of this combo box to be "No" only when the user selects "US", and the formula is "Yes" when the user selects other values, the formula can be written like this:

Switch(
    drpCountry.Selected.Value,
    "US",
    {Value: "No"},
    {Value: "Yes"}
)​

Best Regards,

Bof

View solution in original post

Hi @v-bofeng-msft ,

 

I was able to improve the logic of my formula. Thanks for enlightening me. So here's what I did:

I pull the data from my SharePoint list to the drpCountry. Then I used this formula as suggested:

Switch(
    drpCountry.Selected.Result,
    "United States",
    {Value: "Yes"},
    {Value: "No"}
)​

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,998)