Astra

How to Use OR Function in Excel- 4 Examples

Estimated reading: 6 minutes

The OR function is a well-known member of the logical function family in Excel. The OR function is an excellent choice for validating any of the given logical or conditional sets. The OR function returns the desired value if any of the given multiple arguments are TRUE. The application of the OR function becomes versatile when it is combined with multiple functions like IF, AND, and so on.

In this article, we will have a shot at the application of the OR function in Excel with multiple examples.

Syntax of the OR Function

=OR(logic1, logic2, …)

Argument of the OR Function

logic1—the mandatory argument for evaluation, which can be a condition or logical value (required).

logic2—the optional second condition or logical value to be evaluated (optional).

In a similar way, up to 255 conditions can be added to the argument of the OR function.

Return of OR Function

OR Function returns TRUE if one or more conditions in the array of conditions added to the OR function’s argument are met.

If no condition is compiled, then the OR function returns FALSE.

See the truth table given below.

Example #1: Application of OR function in Excel with multiple logic

Suppose you have given a data set of employee name, performance score, and team name as below.

And you want to provide a reward to the members of team A, plus any other employee whose performance score needs to be greater than 12.

Now, we will apply the following formula to evaluate the above condition.

=OR(D3>10,C3="A")
  • Input the above formula in the output cell E3, and press Enter
  • Then AutoFill the remaining cell in column E
or function in excel examples

Explanation

  • Here, the OR function will return TRUE if any one condition is satisfied. 
  • For Tom, both conditions are satisfied. So, the OR function will return TRUE 
  • But for John, none of the conditions are satisfied. So the result is FALSE.
  • For other employees, see the return table below.

Example #2: Combined application of IF and OR Functions in Excel

With reference to the previous example, you want to show some user-friendly output instead of TRUE or FALSE. That can be obtained by combining the IF function with the OR function.

  • Apply the following formula in the output cell E3
=IF(OR(D3>10,C3="A"),"Eligible","Not Eligible")
  • Press the Enter key and then AutoFill.
or function in excel

Explanation

  • In the formula above, the IF function returns “Eligible” if any one of the conditions given in the argument of the OR function is TRUE.  
  • Let’s check the formula evaluation for Tom,
=IF(OR(D3>10,C3="A"),"Eligible","Not Eligible")

=IF(OR(TRUE,TRUE),"Eligible","Not Eligible")

=IF(TRUE,"Eligible","Not Eligible")

=Eligible
  • But for John, none of the conditions in the argument of the OR function are satisfied. Hence, “Not Eligible” is returned by the IF function.

Example #3: Conditional Checking and Sorting with OR Function

Assume employee names and corresponding performance scores for two months are given in the datasheet. 

If the performance score 1 and performance score 2 are greater than 10 and 11, respectively, you want to calculate the average performance score.

  • To solve this problem in Excel apply the following formula in the output cell F3 and press Enter
=IF(OR(D3>10,E3>11),AVERAGE(D3:E3),"Not applicable")
  • Then AutoFill the remaining cells in column E
or function excel

Explanation

  • IF function will trigger the AVERAGE function only if the OR function returns TRUE.
  • For John, the performance score 1 and the performance score 2 are 10 and 11, respectively. But according to the conditions provided in the argument of the OR function, performance scores need to be greater than 10 and 11, respectively.

Let’s see the formula evaluation for John

=IF(OR(D4>10,E4>11),AVERAGE(D4:E4),"Not applicable")

=IF(OR(FALSE,FALSE),AVERAGE(D4:E4),"Not applicable")

=IF(FALSE,AVERAGE(D4:E4),"Not applicable")

= Not applicable

Sorting Data:

Now, we want to sort the evaluated average value from lowest to highest.

  • Select the data range B2:F7.
  • Navigate to the Data tab.
  • Click on the sort section. A new window will open.
Data sorting or function in excel examples
  • Select the Sort by the “Average Score” and the order should be “Largest to Smallest
  • Then click on the “OK” button.
  • The output is:

Example #4: Highlighting Weekends using OR Function

Assume you have to attend several meetings according to the given schedule. 

You want to mark the weekend, as you don’t like to arrange meetings on the weekend.

We will combine the WEEKDAY function with the OR function to solve this problem. 

  • Select the output data range C3:C7
  • From the Home tab, Click on “Conditional Formatting
  • Select “New rule
conditional formatting or function in excel examples
  • A window named “New Formatting Rule” will open. Then click on the “Use a formula to determine which cells to format”
  • Input the following formula in the input field of “Format values where this formula is true
=OR(WEEKDAY(C3)=7,WEEKDAY(C3)=1)
  • Click on the “Format” button.
  • A window named “Format cells” will open.
  • From the Font tab, select any color.
  • Then click “OK” 
formatting or function in excel examples
  • Again, click the “OK” button on the “New Formatting Rule” window.

The output is

Explanation

  • The WEEKDAY function counts the days of a week in 1 to 7 order and considers Saturday = 7 and Sunday = 1
  • OR function checks that the given date values equal either 7 or 1. If any one condition is satisfied, then the OR function returns TRUE.
  • If the OR function returns true, the cells are highlighted in Red color according to the formatting rule.

Things to Keep in Mind on XOR Function in Excel

  • Any text values or empty cells in the arguments will be neglected by this function.
  • OR function returns #VALUE error if there are no conditions in the argument that interpret any numerical or logical value.
  • Up to 255 conditions or logics can be added to the argument in a single formula.
  • An array formula can be formed using the OR function

OR Function VS XOR Function

The OR function returns TRUE if either of the two arguments is TRUE.

If only one of the arguments is true, XOR returns TRUE. The XOR function, on the other hand, returns FALSE if both arguments are TRUE.

The truth table for the OR and XOR functions can be found here.

xor vs or function in excel

Conclusion

Regardless of your level of experience, knowing how to use the OR function in Excel can help you save time and make more intelligent judgments. Hence, start learning about Excel’s OR function right now to maximize your ability to analyze data and make decisions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Share this Doc
Jump to Topics
SOLVED EXCEL
Scroll to Top