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.
Let’s dive into our OR function Google Sheets guide.
OR Function Google Sheets Syntax
OR in Google Sheets works with the following syntax:
OR(logical_expression1, [logical_expression2, …])
- logical_expression1 – The first condition that you want to check. This could be a cell reference that has the TRUE/FALSE value or an expression that returns logical values.
- [logical_expression2].. – Additional conditions that you want to check.
- OR function can be used with other formulas to be more efficient. For example, if you’re testing two conditions and your final result is ‘Pass’ if any of the two conditions is met. You can use a formula such as =IF(OR(A1=”Pass”,A2=”Pass”),”Pass”,”Fail”).
- The arguments must either evaluate to logical values (TRUE/FALSE), or the arguments must be arrays/references of logical values.
- Text and empty cells are ignored.
- If the specified range contains no logical values, the OR function returns #VALUE! error.
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 – 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.
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 2 – Using a Nested Google Sheets or Statement
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.
Note that this is a case of nested OR functions where one OR function is used with in the other.
Example 3 – Test Multiple Conditions Using the OR Function and IF Function Combined
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 Google Sheets IF OR formula can do this:
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”.
Related Formula: The AND Function
You can use the AND function in Google Sheets in a similar way to the OR function except it means that all the conditions must be met instead. For example, let’s say there is a new virus outbreak and your staff must be vaccinated to continue working. But, the vaccination men and women must receive are different. You know the local hospital has extra vaccinations available for women but not for men. you could use a nested AND function to figure out who can book an appointment, like so:
The formula above uses the AND function to check whether the data in column B is Female AND column C2 is NO, then the IF function shows YES if they’re eligible for vaccination (TRUE) or No if not (FALSE).
Google Sheets OR Function FAQ
What Does the OR Function Do in Google Sheets?
To put it simply, the OR function in Google Sheets checks multiple conditions and returns a TRUE result if any of the conditions or met. This is similar to the AND function, but all conditions must be met in the AND function to return a TRUE result.
How Do You Use the OR Operator in Google Sheets?
Unfortunately, there is no OR short operator in Google Sheets so you must use the OR function instead.
How Do You Use IF AND/OR Formula in Google Sheets Together?
The AND & OR functions can both be used as nested functions. When used with the IF function, this means that the OR or AND function can be used as the logical_expression in the IF function syntax. The syntax of IF functions is:
IF(logical_expression, value_if_true, value_if_false)
So an example of nesting an OR function as the logical_expression to build an IF OR Google Sheets formula could be:
IF(Or(B2=10, B2=5), "Yes", "No)
IF AND Google Sheets formulas work exactly the same, but with AND instead of OR.
If You Found This OR Function Google Sheets Guide Useful, You May Also Like These Related Posts:
- IF Function in Google Sheets.
- IFS Function in Google Sheets.
- IFERROR Function in Google Sheets.
- COUNTIF Function in Google Sheets
- How to Use SWITCH function in Google Sheets