cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
awoodyyc2
Level: Powered On

PowerApps Or operator not working

I'm building a user request form in PowerApps. A number of fields are visible or not visible based on one dropdown selection. I am using the Visible option.

 

If(ReasonForChange_DataCardValue.Selected.Value = "Termination" Or "Leave of Absence" Or "Retirement",true,false)
 
In the above, everything is working when Termination is selected, but anything after that is not working as expected. If I change the above to:

If(ReasonForChange_DataCardValue.Selected.Value = "Leave of Absence" Or "Termination" Or "Retirement",true,false)
 
then things work for Leave of Absence, but not Termination or Retirement. Only the first value returns the expected results. I have tried using || in place of Or and I experience the same results.
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Eelman
Level 10

Re: PowerApps Or operator not working

@awoodyyc2 

 

Unfortunately, you need to include the full condition for all conditions, like this

If(
  ReasonForChange_DataCardValue.Selected.Value = "Termination" Or
  ReasonForChange_DataCardValue.Selected.Value =  "Leave of Absence" Or 
  ReasonForChange_DataCardValue.Selected.Value = "Retirement",true,false)

 

 

View solution in original post

3 REPLIES 3
Highlighted
Eelman
Level 10

Re: PowerApps Or operator not working

@awoodyyc2 

 

Unfortunately, you need to include the full condition for all conditions, like this

If(
  ReasonForChange_DataCardValue.Selected.Value = "Termination" Or
  ReasonForChange_DataCardValue.Selected.Value =  "Leave of Absence" Or 
  ReasonForChange_DataCardValue.Selected.Value = "Retirement",true,false)

 

 

View solution in original post

EricLott
Level 10

Re: PowerApps Or operator not working

@awoodyyc2 @Eelman 

This syntax also works

ReasonForChange_DataCardValue.Selected.Value in ["Leave of Absence","Termination","Retirement"]

You also don't need the If() statement since you're returning true or false for the true/false case. Example, these two function are interchangeable:

If(myVariable = "foo",true,false) 

myVariable = "foo"

 ---
If this answered your question, please click "Accept Solution". If this helped, please Thumbs Up.

Eelman
Level 10

Re: PowerApps Or operator not working

@EricLott 

Nice! I love code refactoring, thanks for the share 🙂 

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

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