IF Function mastery with Logical Function (AND/OR)

Explore other logical functions like AND and OR, which can be combined with IF function to handle in more complex scenarios.

  • OR Function: The OR in Excel is a logical function that returns either “TRUE” or “FALSE” based on two or more conditions. For example:

Let’s take an example where you want to segregate Fruits according to their Colour as shown below.

In this type of situation, we use the combination of the IF with the OR Function to handle two or more conditions as shown below. In Excel, we say this as “Either Situation” where we use OR function.

IF function with OR fuction

=IF(OR(A2=”Apple”, A2=”Strawberry”, A2=”Rasberry”), “Red”, IF(OR(A2=”Pear”, A2=”Guava”), “Green”,”Yellow”))

I know this formula creates confusion, but I assure you, once you learn this logic to apply it will definitely help you in future.

Let us understand the logic of the formula:

1st Condition OR(A2=”Apple”, A2=”Strawberry”, A2=”Rasberry”)

=IF(logical_test, value_if_true, value_if_false)

  • logical_test: Here, the OR function evaluates the corresponding values in cell A2 and It returns TRUE if the condition matches and FALSE if not match.
  • value_if_true: It checks the logical_test value whether It’s TRUE or FALSE, and performs the equation accordingly. For example, The 1st condition is met and returns TRUE from cell A2 (Apple) and matched to the “Red”.
  • value_if_false: If FALSE then the 2nd condition will be evaluated by the IF function.

2nd Condition OR(A5=”Pear”, A5=”Guava”)

=IF(logical_test, value_if_true, value_if_false)

  • logical_test: The OR function evaluates the corresponding values in cell A5 and It returns TRUE if matched and FALSE if not match.
  • value_if_true: If the value returns TRUE then it gives “Green”
  • value_if_false: If both conditions are not met it returns “Yellow”.

5. Handling Errors

The IF function can be useful for managing errors. If you expect potential errors in your data, you can use the IFERROR along with IF to provide a specific response in case of an error.

=IFERROR(DIVIDE(A1, B1), “Error: Division by Zero”)

In this example, if a division by zero error occurs, it returns the custom error message.

Leave a Comment

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