# Blog

# Formula - Boolean And / Or operators - What is the order of precedence?

December 16. 2021

When we construct expressions that include the Boolean And and Or operators, which operator takes precedence? Find out in this post.

When building logical expressions with Power Apps, it's useful to understand which operator takes precedence when we mix the And and Or operators.

## Demonstration - Filtering records with the And and Or operators

As an example, let's assume that we build an app that's based on a table of properties as shown beneath. The requirement is to search for all properties in London, which contain either 5 or more bedrooms, or 3 or more bathrooms.

Let's now add a gallery control and set the Items property to the formula beneath. Will this formula return the expected results?

Filter(`Property,`

`City="London" And`

`Bedrooms >= 5 Or`

`Bathrooms >= 3`

)

The answer to the above question is No! As the screenshot beneath highlights, this formula returns records for properties that are
not in London.

## The And operator takes precedence over Or

This example highlights how the And operator takes precedence over the Or operator. To return our desired results, it's therefore necessary to parenthesis the Or part of the statement. The correct formula will look like this:

Filter(

`Property`

,

`City="London" And`

`(`

Bedrooms >= 5 Or

`Bathrooms >= 3`

)

)

As the screenshot beneath shows, this formula now returns the expected results.

## Conclusion

When constructing boolean expressions, Power Apps performs the And/&& operators before the logical Or/|| operators.

- Categories:
- formula

__Related posts__

- Formula - What to do when the If statement doesn't work?
- Controls - How to set the data source of a Combo Box to a comma separated string
- Numbers - 10 examples of how to round numbers
- Formula - Difference between round, square, and curly brackets
- Top 3 highlights of upcoming enhancements to the Power Apps language (Power FX)
- Email - Sending email attachments with the Office 365 Outlook connector
- Formula - What to try when numbers don't format correctly
- Controls - How to convert HTML to Text
- Formulas - how to return all days between two dates
- Formula - How to create comma separated (CSV) list of items
- Formula - How to use the IF and Switch functions - 3 common examples
- Location - Finding the closest location and and sorting records by distance, based on the current location of the user
- Formulas - How to cope with weekends and public holidays in date calculations