cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dave8
Impactful Individual
Impactful Individual

How to use OR in IF condition to verify control values?

Hello,

 

I have three controls as follows:

 

  • Dropdown1
  • Dropdown2
  • Dropdown3

On Submit Button click, I need to verify if any of the value is blank, therefore, I have applied following formula on button click:

 

If(IsBlank(Dropdown1.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown2.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown3.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }))

 

Although above is working as expected, I need something as follows:

 

If any of the dropdown values are blank, "Result 1", "Result 2"

 

If and Switch condition did not work for me, Also "Or" or "||" operators were not resulting as expected too. Probably I am doing something wrong, but I gave up!

 

Can you please help me in optimizing this formula further?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions

@dave8 
Here you go... I made a small syntax error.  Missing a closing bracket on the last line.

If(
    !IsBlank(Dropdown1.Selected.Value)=true,
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false})
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
mdevaney
Super User
Super User

@dave8 

I think this is the formula you will need to check if all the dropdown inputs have a value.

 

If(
    !IsBlank(Dropdown1.Selected.Value)=true,
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false}
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

dave8
Impactful Individual
Impactful Individual

Thank you for your attention, however it still throws an error:

 

Note: I have removed "," after first condition, as it was not needed in formula.

 

valerror.png

What could be wrong? I have faced the same error while trying earlier as well with other alternatives!

 

Thanks!

@dave8 
Here you go... I made a small syntax error.  Missing a closing bracket on the last line.

If(
    !IsBlank(Dropdown1.Selected.Value)=true,
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false})
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

dave8
Impactful Individual
Impactful Individual

Thank you!

 

Below formula has removed syntax error, however it doesn't execute the Result One!

 

If(
    !IsBlank(Dropdown1.Selected.Value)=true
    And !IsBlank(Dropdown2.Selected.Value)=true
    And !IsBlank(Dropdown3.Selected.Value)=true,
    UpdateContext({ValidationConfirm: true}),
    UpdateContext({ValidationConfirm: false})
)

 

While below formulas does:

 

If(IsBlank(Dropdown1.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown2.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

If(IsBlank(Dropdown3.Selected.Value)=true,UpdateContext({ValidationConfirm:true}),UpdateContext({ValidationConfirm : false }));

 

I have also faced above behaviour earlier, What could be missing now?

 

Thanks,

 

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.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

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.

Top Solution Authors
Users online (3,077)