web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / AND works, OR works, b...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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
      )
Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

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

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

         )
    )

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    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,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard