Determines if any of the conditions in the test is TRUE
Over 1.8 million professionals use CFI to learn accounting, financial analysis, modeling and more. Start with a free account to explore 20+ always-free courses and hundreds of finance templates and cheat sheets.
The OR Function[1] is categorized under Excel LOGICAL functions. The function will determine if any of the conditions in a test is TRUE.
In financial analysis, the OR function can be useful in comparing two statements or two values. For example, A1 for either “a” or “b,” use =OR(A1=”a”,A1=”b”). The function can be used as the logical test inside the IF function to avoid extra nested IFs, and can be combined with the AND function.
Formula
=OR(logical1, [logical2], …)
The function uses the following arguments:
Logical1 (required argument) – This is the first condition or logical value to evaluate.
Logical2 (optional argument) – The second condition or logical value to evaluate.
How to use the OR Function in Excel?
As a worksheet function, it can be entered as part of a formula in a cell of a worksheet. To understand the uses of the function, let us consider an example:
Example 1
Let’s see how we can test a few conditions. Suppose we are given the following data:
We get the results below:
In the above examples:
The function in cell E4 evaluates to TRUE, as BOTH of the supplied conditions are TRUE;
The function in cell E5 evaluates to TRUE, as the first condition, B5>0 evaluates to TRUE;
The function in cell E6 evaluates to FALSE, as ALL of the supplied conditions are FALSE.
Example 2
Let us now nest OR with IF. Suppose we are given student marks and we want the formula to return “PASS” if marks are above 50 in Economics or above 45 in Business Studies and “FAIL” for marks below it.
The formula to use is:
We get the results below:
Even if any one condition is satisfied, this function will return PASS.
Example 3
Suppose we want to highlight dates that occur on weekends. We can use the OR and WEEKDAY functions. Suppose we are given the data below:
Using conditional formatting, we can highlight cells that fall on weekends. For that, select the cells B2:B6 and in Conditional Formatting, we will put the formula =OR(WEEKDAY(B2)=7,WEEKDAY(B2)=1, as shown below:
We get the results below:
This formula uses the WEEKDAY function to test dates for either a Saturday or Sunday. When given a date, WEEKDAY returns a number 1-7, for each day of the week. In their standard configuration, Saturday = 7 and Sunday = 1. By using the OR function, we used WEEKDAY to test for either 1 or 7. If either is true, the formula will return TRUE and trigger the conditional formatting.
If we wish to highlight the entire row, we need to apply the conditional formatting rule to all columns in the table and lock the date column. The formula to use will be =OR(WEEKDAY($B2)=7,WEEKDAY($B2)=1).
A few things to remember about the OR Function:
We can use the function to test multiple conditions at the same time – up to 255 conditions in total.
#VALUE! error – Occurs if any of the given logical_test cannot be interpreted as numeric or logical values.
The function can also be used with the AND function, depending on the requirement.
If we enter OR as an array formula, we can test all values in a range against a condition. For example, the array formula will return TRUE if any cell in A1:A100 is greater than 15 ={OR(A1:A100>15}.
This function will ignore the text values or empty cells provided in the arguments.
Thanks for reading CFI’s guide to important Excel functions! By taking the time to learn and master these functions, you’ll significantly speed up your financial analysis. To learn more, check out these additional CFI resources:
Take your learning and productivity to the next level with our Premium Templates.
Upgrading to a paid membership gives you access to our extensive collection of plug-and-play Templates designed to power your performance—as well as CFI's full course catalog and accredited Certification Programs.
Gain unlimited access to more than 250 productivity Templates, CFI's full course catalog and accredited Certification Programs, hundreds of resources, expert reviews and support, the chance to work with real-world finance and research tools, and more.