Enrollment for the FMVA™ Certification Program is now OPEN!

OR Function

Determines if any of the conditions in the test is TRUE

What is the OR Function?

The OR Function is categorized under LOGICAL functions. The function will determine if any of the conditions in the 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 OR 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 OR Function uses following arguments:

  1. Logical1 (required argument) – It is the first condition or logical value to evaluate.
  2. Logical2 (optional argument) – It is the second condition or logical value to evaluate.

 

How to use the OR Function in Excel?

As a worksheet function, OR 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 few conditions. Suppose we are given the following data:

 

OR Function

 

We get the results below:

 

OR Function - Example 1

 

In the above examples:

  1. The function in cell E4 evaluates to TRUE, as BOTH of the supplied conditions are TRUE;
  2. The function in cell E5 evaluates to TRUE, as the first condition, B5>0 evaluates to TRUE;
  3. 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.

 

OR Function - Example 2

 

The formula to use is:

 

OR Function - Example 2a

 

We get the results below:

 

OR Function - Example 2b

 

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:

 

OR Function - Example 3

 

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:

 

OR Function - Example 3a

 

 

We get the results below:

 

OR Function - Example 3b

 

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 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).

 

Few things to remember about the OR Function:

  1. We can use the OR function to test multiple conditions at the same time – up to 255 conditions in total.
  2. #VALUE! error – Occurs if any of the given logical_test cannot be interpreted as numeric or logical values.
  3. The OR function can also be used with AND function depending on the requirement.
  4. 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}.
  5. The OR function will ignore the text values or empty cells provided in the arguments.

 

Click here to download the sample Excel file

 

Additional resources

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 resources:

Free Excel Tutorial

To master the art of Excel, check out CFI's FREE Excel Crash Course, which teaches you how to become an Excel power user.  Learn the most important formulas, functions, and shortcuts to become confident in your financial analysis.  

Launch CFI’s Free Excel Course now to take your career to the next level and move up the ladder!