IF, AND, OR, Nested IF & NOT Logical Functions in Excel

โšก Smart Summary

Logical Functions in Excel add decision making to formulas by testing whether a condition is true or false. This page explains the IF function with a worked budget example, the AND, OR, NOT, IFERROR, and IFNA functions, and nested IF statements for more than two outcomes.

  • ๐Ÿ”€ Core Purpose: A logical function introduces decision making, checking whether a condition is true or false and combining several conditions.
  • โ“ Condition: A condition is an expression that evaluates to true or false, such as E4 being less than 6000.
  • โœ… IF Function: =IF(logical_test, value_if_true, value_if_false) returns one value when the test passes and another when it fails.
  • ๐Ÿ”— AND and OR: AND returns true only when every condition is true, and OR returns true when any condition is true.
  • ๐Ÿšซ NOT and Error Handlers: NOT reverses a true or false result, IFERROR traps any error, and IFNA traps only the #N/A error.
  • ๐Ÿช† Nested IF: An IF inside another IF handles more than two outcomes, such as a different message for each day.

Logical Functions in Excel IF AND OR NOT

Things will not always be the way we want them to be. The unexpected can happen. For example, let’s say you have to divide numbers. Trying to divide any number by zero (0) gives an error. Logical functions come in handy such cases. In this tutorial, we are going to cover the following topics.

What is a Logical Function?

It is a feature that allows us to introduce decision-making when executing formulas and functions. Functions are used to;

  • Check if a condition is true or false
  • Combine multiple conditions together

What is a condition and why does it matter?

A condition is an expression that either evaluates to true or false. The expression could be a function that determines if the value entered in a cell is of numeric or text data type, if a value is greater than, equal to or less than a specified value, etc.

IF Function example

We will work with the home supplies budget from this tutorial. We will use the IF function to determine if an item is expensive or not. We will assume that items with a value greater than 6,000 are expensive. Those that are less than 6,000 are less expensive. The following image shows us the dataset that we will work with.

IF Function Example in Excel

  • Put the cursor focus in cell F4
  • Enter the following formula that uses the IF function
=IF(E4<6000,"Yes","No")

HERE,

  • “=IF(โ€ฆ)” calls the IF functions
  • “E4<6000” is the condition that the IF function evaluates. It checks the value of cell address E4 (subtotal) is less than 6,000
  • “Yes” this is the value that the function will display if the value of E4 is less than 6,000
  • “No” this is the value that the function will display if the value of E4 is greater than 6,000

When you are done press the enter key

You will get the following results

IF Function Example in Excel

Excel Logic functions explained

The following table shows all of the logical functions in Excel

S/N FUNCTION CATEGORY DESCRIPTION USAGE
01 AND Logical Checks multiple conditions and returns true if they all the conditions evaluate to true. =AND(1 > 0,ISNUMBER(1)) The above function returns TRUE because both Condition is True.
02 FALSE Logical Returns the logical value FALSE. It is used to compare the results of a condition or function that either returns true or false FALSE()
03 IF Logical Verifies whether a condition is met or not. If the condition is met, it returns true. If the condition is not met, it returns false.
=IF(logical_test,[value_if_true],[value_if_false])
=IF(ISNUMBER(22),”Yes”, “No”)
22 is Number so that it return Yes.
04 IFERROR Logical Returns the expression value if no error occurs. If an error occurs, it returns the error value =IFERROR(5/0,”Divide by zero error”)
05 IFNA Logical Returns value if #N/A error does not occur. If #N/A error occurs, it returns NA value. #N/A error means a value if not available to a formula or function. =IFNA(D6*E6,0)
N.B the above formula returns zero if both or either D6 or E6 is/are empty
06 NOT Logical Returns true if the condition is false and returns false if condition is true =NOT(ISTEXT(0))
N.B. the above function returns true. This is because ISTEXT(0) returns false and NOT function converts false to TRUE
07 OR Logical Used when evaluating multiple conditions. Returns true if any or all of the conditions are true. Returns false if all of the conditions are false =OR(D8=”admin”,E8=”cashier”)
N.B. the above function returns true if either or both D8 and E8 admin or cashier
08 TRUE Logical Returns the logical value TRUE. It is used to compare the results of a condition or function that either returns true or false TRUE()

Nested IF functions

A nested IF function is an IF function within another IF function. Nested if statements come in handy when we have to work with more than two conditions. Let’s say we want to develop a simple program that checks the day of the week. If the day is Saturday we want to display “party well”, if it’s Sunday we want to display “time to rest”, and if it’s any day from Monday to Friday we want to display, remember to complete your to do list.

A nested if function can help us to implement the above example. The following flowchart shows how the nested IF function will be implemented.

Nested IF Functions in Excel

The formula for the above flowchart is as follows

=IF(B1="Sunday","time to rest",IF(B1="Saturday","party well","to do list"))

HERE,

  • “=IF(โ€ฆ.)” is the main if function
  • “=IF(โ€ฆ,IF(โ€ฆ.))” the second IF function is the nested one. It provides further evaluation if the main IF function returned false.

Practical example

Practical Example of Nested IF Functions

Create a new workbook and enter the data as shown below

Practical Example of Nested IF Functions

  • Enter the following formula
=IF(B1="Sunday","time to rest",IF(B1="Saturday","party well","to do list"))
  • Enter Saturday in cell address B1
  • You will get the following results

Practical Example of Nested IF Functions

Download the Excel file used in Tutorial

IF vs Nested IF vs IFS

Excel offers three ways to return different results from conditions, and choosing the right one keeps the formula readable. A single IF handles two outcomes, a nested IF handles several, and the newer IFS function replaces a long nested IF.

Approach Number of outcomes Example
IF Two, a true value and a false value =IF(E4<6000,”Yes”,”No”)
Nested IF Several, one IF inside another =IF(B1=”Sunday”,”rest”,IF(B1=”Saturday”,”party”,”to do”))
IFS Several, without the closing brackets of a nested IF =IFS(B1=”Sunday”,”rest”,B1=”Saturday”,”party”,TRUE,”to do”)

๐Ÿ’ก Tip: Keep nesting to a few levels. When a formula grows past three or four nested IF functions, switch to IFS, or use a lookup table with VLOOKUP, because a long nested IF is hard to read and to correct.

FAQs

AND returns TRUE only when every condition is true, so all tests must pass. OR returns TRUE when at least one condition is true. AND is stricter, OR is more permissive.

IFERROR traps every error type, including #DIV/0! and #VALUE!. IFNA traps only the #N/A error. Use IFNA after a VLOOKUP when you want to catch a missing match but still see other errors.

Put AND or OR inside the logical test of IF, for example =IF(AND(E4>0,E4<6000),”Yes”,”No”). The IF then returns its value based on the combined condition that AND or OR evaluates.

Yes. AI features such as Copilot in Excel turn a plain request like “show Pass when the score is at least 50, otherwise Fail” into =IF(C2>=50,”Pass”,”Fail”). The user reviews the logic before applying it.

Yes. AI assistants read a long nested IF and rewrite it as an IFS function or suggest a lookup table, then explain the change. The user confirms the outcomes match before replacing the original formula.

Summarize this post with: