cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

AND works, OR works, but not AND( OR( ) ) ?

Hello, 

Need some eyes on this.. I feel like I've run into this before but can't recall what I'm doing wrong. 

Scenario:

  • Toggle1 Control INSIDE a Gallery
  • Toggle2 Control OUTSIDE a Gallery
  • Trying to build a "Toggle-all" option outside the Gallery
  • Trying to set the Default Property of Toggle1 based on Toggle2 

Toggle1- INSIDE Gallery:

  • Here are the debug steps I've taken (read code comments):
    • /*===================================================
      Results in "pass"
      ===================================================*/
      If( Or( ThisItem.status = "off", IsBlank(ThisItem.status) ), "pass", "fail")
      /*===================================================
      Results in "pass"
      ===================================================*/ If( Toggle2.Value = true, "pass", "fail")
      /*===================================================
      Results in "fail" WHY?
      ===================================================*/ If(
      Or(
      ThisItem.status = "off",
      IsBlank(ThisItem.status)
      ),
      false,
      And(
      Or(
      ThisItem.status = "off",
      IsBlank(ThisItem.status)
      ),
      Toggle2.Value = true
      ),
      Toggle2.Value,
      true
      )
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: AND works, OR works, but not AND( OR( ) ) ?

Hi @ericonline ,

Could you please share a bit more about your scenario?

Could you please show more details about the "Results in "fail" WHY?"? What happens with your formula?

 

Based on the formula that you mentioned, I think there is something issue with it. If the first condition within your If function is true, the result your If function returns is always true, regardless of whether you check or uncheck your Toggle 2 control.

In other words, if the first condition in your If function is met, the following conditions within the If function would not be executed.

More details about the If function in PowerApps, please check the following article:

If function

 

I have made a test on my side, please take a try with the following formula (set the Default property of the Toggle 1 control to following😞

If(
    Toggle2.Value = true,
    true,     /* <-- You could also consider type Toggle2.Value here */
    If(
          ThisItem.status = "off" || IsBlank(ThisItem.status),
          false,
          true
      )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: AND works, OR works, but not AND( OR( ) ) ?

@ericonline  so in your formula, I read it as:

If ConditionA is true, false, otherwise If ConditionB is true, then true.

Condition A is field is "off" or Blank

Condition B is field is "off" or Blank and Toggle is true and Toggle is true (you are and'ing the toggle value twice).

 

So, if I boil this down, I am seeing that you are really just looking to see if any of these conditions are met. 

If I look at the inverse of the problem, it seems that, if the item is "on" and not Blank, it should be "on"/true.

 

What I am missing from your end-goal is, are you trying to use the Toggle2 as a master "on" or master "off" toggle?

 

If you are trying to do master "on", then your formula should be:

   !(ThisItem.Status="Off") || IsBlank(ThisItem.Status) || Toggle2.Value

If the status is not "off" or the status is blank or the toggle is on = set to on.

Or:

  (!(ThisItem.Status2="Off") && !IsBlank(ThisItem.Status2)) || Toggle22.Value

If the status is not "off" and the status is not blank OR the toggle is on = set to on

Or:

  !(ThisItem.Status2="Off") && !IsBlank(ThisItem.Status2) || (Toggle22.Value && !IsBlank(ThisItem.Status2))

If the status is not "off" and the status is not blank OR the toggle is on and the status is not blank = set to on

 

You might give the shortened notation (&& || !) a try over using the And, Or and Not as a formula - makes it a little easier to digest the logic.

 

Hope this helps some.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Anonymous
Not applicable

Re: AND works, OR works, but not AND( OR( ) ) ?

You will need to add an If(  in front of the And, along with the closing ). In BOLD below.

===================================================*/
If(

    Or(
        ThisItem.status = "off",
        IsBlank(ThisItem.status)
    ),
    false,
    If(And(
        Or(
            ThisItem.status = "off",
            IsBlank(ThisItem.status)
        ),
        Toggle2.Value = true
        ),
        Toggle2.Value,
    true

     )
)

Community Support Team
Community Support Team

Re: AND works, OR works, but not AND( OR( ) ) ?

Hi @ericonline ,

Could you please share a bit more about your scenario?

Could you please show more details about the "Results in "fail" WHY?"? What happens with your formula?

 

Based on the formula that you mentioned, I think there is something issue with it. If the first condition within your If function is true, the result your If function returns is always true, regardless of whether you check or uncheck your Toggle 2 control.

In other words, if the first condition in your If function is met, the following conditions within the If function would not be executed.

More details about the If function in PowerApps, please check the following article:

If function

 

I have made a test on my side, please take a try with the following formula (set the Default property of the Toggle 1 control to following😞

If(
    Toggle2.Value = true,
    true,     /* <-- You could also consider type Toggle2.Value here */
    If(
          ThisItem.status = "off" || IsBlank(ThisItem.status),
          false,
          true
      )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

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