0% found this document useful (0 votes)
85 views

Excel If Function

Uploaded by

Mohib
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Excel If Function

Uploaded by

Mohib
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Another time-saving resource from:

Data Analysis with the IF Function


Dawn Bjork, MCT, MOSM, CSP For Microsoft Excel 365, 2021, 2019, 2016
TheSoftwarePro.com

The Basics (Getting Started)


In Excel, the IF() function performs a calculation or other entry only if a specific condition is true, and to
perform a different calculation or entry if that condition is false. The cell or entry that is evaluated may
be a formula, value, or text; the displayed result may also be a formula, value, or text answer. For
example, if amount is more than 5% over budgeted amount, then display “OVER”, otherwise show
“OK.” The structure or syntax for the IF() function is:
What happens if
first part (the test) is
What is being
false
analyzed, evaluated
or “tested” =IF(logical_test, value_if_true, value_if_false)
What happens if
first part (the test) is
true
• Logical_test is any value or expression resulting in TRUE or FALSE.
• Value_if_true is the value (or formula result) that will be returned if logical_test is TRUE.
• Value_if_false is the value (or formula result) that will be returned if logical_test is FALSE.

The result values can display text with an argument such as "OK", calculate a formula such as B12*5,
or display the contents of a cell. Text results must be entered into an IF() function as a character string,
that is, in double quotations. Spaces after the commas in the IF() function are optional.

Examples:
Simple IF() function formulas * Explanation
=IF(B2>100, B2*1.25, B2) If the value in cell B2 is greater than 100, multiply
that value by 1.25, otherwise just display the value in
B2 in the cell where the formula is entered.
=IF(C34>=B34, C34, "Entry not valid") If the value in cell C34 is greater than or equal to the
value in cell B34, display the value in C34, otherwise
display the text "Entry not valid".
=IF(D10<2500, "No", "Yes") If the value in cell D10 is less than 2500, display "No",
otherwise display "Yes".
* As with all other Excel functions, IF() functions can be copied and the logic will copy as well.

© Dawn Bjork, The Software Pro® • TheSoftwarePro.com • Certified Speaking Professional (CSP)
Microsoft Certified Trainer (MCT) • Certified Microsoft Office Specialist Master (MOSM) • Certified Microsoft Excel Expert
Excel 365, 2021, 2019,& 2016: Data Analysis with the IF Function Page 2

Multiple Conditions (More Advanced)


Checking Complex Conditions
Use the AND(), OR(), and NOT() functions with the IF() function to make complex decisions.

AND Checks If More Than One Condition is True


The general structure of AND() function used with IF() function is as follows:

=IF(AND(expression1, expression2), value_if_true,


value_if_false)

There can be up to 30 expressions as arguments to the AND() function, and all must evaluate true for
the AND() function to evaluate true.

OR Checks If One Condition is True


The AND() function requires that all expressions are true. The syntax of the OR() function is identical
and there can be up to 30 expressions as arguments to the OR() function, but only one of the
expressions must be true for the OR() function to evaluate true.

The general structure of OR() function used with IF() function is as follows:

=IF(OR(expression1, expression2), value_if_true,


value_if_false).

NOT Returns Opposite Condition


The NOT() function reverses the result of the logical argument from true to false or from false to true.
Use this function to return the opposite condition of the logical_test in an IF() statement.

Examples:
Complex IF() function formulas Explanation
=IF(AND(B12>5, B12<20), "Good", If the contents of cell B12 is more than 5 and less
"Invalid") than 20, the text "Good" displays, otherwise the
text "Invalid" appears.
=IF(OR(C5="ABC", C5="DEF", C5="GHI"), If cell C5 contains "ABC", "DEF", or "GHI" (in upper
"Correct entry", "Wrong entry") or lower case), display "Correct entry" in the
formula cell, otherwise display "Wrong entry".
=IF(OR(B36=12, B36=20), "Is a 12 or If B36 contains either 12 or 20, displays the text "Is
20", "Not a 12 or 20") a 12 or 20", otherwise displays "Not a 12 or 20".
=IF(NOT(OR(B36=12, B36=20)), "Not a 12 If B36 contains neither 12 or 20, displays the text
or 20", "Is a 12 or 20") "Not a 12 or 20", otherwise displays "Is a 12 or 20".

© Dawn Bjork, The Software Pro® • TheSoftwarePro.com • Certified Speaking Professional (CSP)
Microsoft Certified Trainer (MCT) • Certified Microsoft Office Specialist Master (MOSM) • Certified Microsoft Excel Expert
Excel 365, 2021, 2019,& 2016: Data Analysis with the IF Function Page 3

Helpful Functions with IF


In addition to OR, AND, NOT, these functions are valuable options to evaluate the logical_test.

ISERROR(value)
Tests if the value is an error
ISNA(value)
Tests if the value is an error, specifically #N/A
ISBLANK(value)
Tests if the value is blank
ISNONTEXT(value)
Tests if the value is not text
ISNUMBER(value)
Tests if the value is a number

Nested Functions
When a function’s argument is another function, it is called a nested function. With Excel, you can nest
up to 64 levels of functions in a formula! Although many of Excel’s functions can be nested, this is a
common practice with the IF() function. Use of the AND(), OR(), and NOT() functions within the IF()
function are examples of nested functions; additional samples are given below. One of these examples
includes how to handle an IF() function with multiple logical_test and multiple value_if_true
arguments.

Examples:
Nested function formulas Explanation
=IF(ISBLANK(G4),”Data Missing”, If the entry in cell G4 is blank, display "Data Missing".
G4*J4) Otherwise calculate G4*J4.
=IF(D4>DATEVALUE("1/1/22"), "OK", If the date entry in cell D4 is greater than 1/1/22,
"Enter date after 1/1/22") enter OK in cell, otherwise the phrase "Enter date
after 1/1/22" appears.
=IF(AND(ISTEXT(B5), ISBLANK(C5)), This IF() function combines with the Excel functions
"Must enter last name", "") ISTEXT() and ISBLANK(). In this example, if there is
text in cell B5 (such as a first name), and cell C5 is
blank, then the formula cell will display the text
"Must enter last name", otherwise the formula cell
will display nothing.
=IF(AND(A1>=0, B1>=0), A1+B1, This complex IF() function has multiple logical_test
IF(AND(A1<0, B1<0), -A1-B1, "Both arguments and multiple value_if_true arguments. The
Negative and Positive values value_if_false argument is only added at the end of
entered")) the entire expression.

When troubleshooting a nested function or other IF() function that is not working, count the
number of open and close parentheses ( ) to make sure that every function has a matching set
of parentheses. Excel also adds color to each parenthesis to make it easier to match up the sets
of parentheses. Also, count the number of open and close quotations " " to ensure that every
text entry (character string) has a matching set of quotations.

© Dawn Bjork, The Software Pro® • TheSoftwarePro.com • Certified Speaking Professional (CSP)
Microsoft Certified Trainer (MCT) • Certified Microsoft Office Specialist Master (MOSM) • Certified Microsoft Excel Expert

You might also like