In Microsoft Excel, logical functions are used to test whether a statement is TRUE or FALSE. The most common logical function is the IF statement, which allows you to perform an action based on a single condition.
But what if you need to test multiple conditions? What if a student passes a class if they score above 90 on the final exam or if they complete the extra credit project? This is exactly where the OR function becomes essential.
Understanding the Syntax
The OR function evaluates multiple logical tests at the same time. If any single one of the conditions is true, it returns TRUE. It will only return FALSE if absolutely every condition fails.
Syntax: =OR(logical1, [logical2], ...)
- logical1: The first condition you want to test (e.g., A1>90).
- logical2: (Optional) The second condition you want to test (e.g., B1=”Yes”).
You can stack up to 255 different conditions inside a single OR function.
Basic Example: The Standalone OR Function
Imagine you have a list of sales employees. Cell B2 contains their total sales for the quarter, and cell C2 contains their customer satisfaction score.
To earn a bonus, they must either achieve more than $10,000 in sales, or they must have a satisfaction score of exactly 100.
You would type this formula into D2:
=OR(B2>10000, C2=100)
- If B2 is 12,000 and C2 is 85, the formula returns TRUE (because the sales goal was met).
- If B2 is 8,000 and C2 is 100, the formula returns TRUE (because the satisfaction goal was met).
- If B2 is 8,000 and C2 is 85, the formula returns FALSE (because both conditions failed).
Advanced Example: Nesting OR inside an IF Statement
While seeing TRUE or FALSE on a spreadsheet is helpful, it is usually better to trigger a specific calculation or return a specific text phrase based on the result. To do this, you must place the entire OR function inside the logical test section of an IF function.
Using the same sales bonus example, let’s say you want Excel to automatically print the word “Bonus” if they met either condition, and “No Bonus” if they failed both.
The Formula:
=IF(OR(B2>10000, C2=100), "Bonus", "No Bonus")
How it works:
- Excel looks at the IF function. The very first thing the IF function demands is a logical test.
- It runs the OR function:
OR(B2>10000, C2=100). - If the OR function evaluates to TRUE, the IF function moves to the second argument and prints “Bonus”.
- If the OR function evaluates to FALSE, the IF function moves to the third argument and prints “No Bonus”.
By nesting OR inside an IF statement, you can build incredibly complex, automated decision trees that handle multiple variables seamlessly.