Productivity Spot

How to Use OR Function in Google Sheets (with Examples)

OR function is useful when you want to evaluate a set of conditions.

It will return TRUE when any of the conditions being checked are met, else it returns FALSE.

OR Function Syntax

OR(logical_expression1[logical_expression2, …])

Additional Notes:

OR Function in Google Sheets – Examples

Now let’s look at some examples where you can use the OR function in Google Sheets.

Example 1 – Test Multiple Conditions Using OR Function

Suppose you have a dataset as shown below and you want to find it any of the tests passed. If any of the tests pass, the formula should return PASS, else it should return FAIL.

The below formula can do this:

=ArrayFormula(IF(OR(B2:B4="Pass"),"Pass","Fail"))

Note that this is an array formula as we are testing multiple cells at one go. You don’t need to write this formula this way. You can simply write the formula =OR(B2:B4=“Pass”) and then use Control + Shift + Enter instead of just using Enter.

In the above formula, OR function evaluates the cells and returns TRUE if any of the tests is a ‘pass’, else it returns a false. If function then uses this result to return “Pass” or “Fail”.

Example 2 – Check Whether a Date is a Weekend Day Or Not

Suppose you have a dataset as shown below:

You can use the OR function along with the WEEKDAY function to check if the day is a weekend or not.

Below formula would return TRUE if it’s a weekend day, else it will return FALSE.

=OR(WEEKDAY(A2,2)=6,WEEKDAY(A2,2)=7)

In this formula, the weekday function returns 6 for a ‘Saturday’ and 7 for a ‘Sunday’. OR function then returns TRUE when the result of WEEKDAY function is 6 or 7.

Example 3 – Using Nested OR function

Suppose you have a dataset as shown below:

In the above case, access is granted only if you are from either Marketing or Sales department or you have the A grade classification.

The below formula will give TRUE if access is to be granted and FALSE if the conditions are not met and access is not to be granted.

=OR(OR(A2="Marketing",A2="Sales"),B2="A")

Note that this is a case of nested OR functions where one OR function is used with in the other.

Related Google Sheets Functions:

FREE Google Sheets Tips Ebook

Get Work Done Faster with these 10 Google Sheets Tips

X