Mastering the Order of Precedence Using OR in PowerApps with Boolean Operators

Mastering the Order of Precedence: Using OR in PowerApps with Boolean Operators

Understanding the Order of Precedence: OR in PowerApps and Boolean Operators

When diving deep into the world of logical expressions, especially with PowerApps, it becomes imperative to understand the hierarchy of the Boolean operators And and OR. In this guide, we’ll shed light on which operator claims precedence, ensuring a seamless PowerApps experience.

Demonstrating the And and OR Operators in PowerApps

For a clearer picture, envision creating an app grounded on a properties table. The goal? Searching properties located in London, boasting either 5+ bedrooms or 3+ bathrooms.

Setting up the Gallery Control

Once you add a gallery control, you might be tempted to set its Items property to the following formula:

Filter(
       RealEstateData,
       Location="London" And 
       Rooms >= 5 Or 
       Washrooms >= 3
)

But does this formula provide the anticipated outcome? Unfortunately, no! It fetches records of properties even outside London.

Decoding the Precedence: And vs. OR in PowerApps

The demonstration above pinpoints how the And operator dominates over the OR operator in PowerApps. To fetch the expected outcome, enclose the OR segment within parentheses. Here’s how the refined formula looks:

Filter(
       RealEstateData,
       Location="London" And 
       (
          Rooms >= 5 Or 
          Washrooms >= 3
       )
)

Now, the formula correctly fetches the anticipated properties.

Wrapping Up

When framing boolean expressions in PowerApps, the platform processes the And/&& operators before moving to the logical Or/|| operators. It’s essential to know the order of precedence to ensure accurate results. PowerApps, with its array of functions and capabilities, can sometimes pose challenges. However, with the right guidance and understanding of its intricacies, you can harness its full potential.

If you stumble upon any challenges or need a deeper insight into “OR in PowerApps” or any other technical realm, feel free to contact us. We’re here to guide, assist, and if required, offer specialized technical support for a fee.

About The Author