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

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
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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (4,269)