Test1
Test 2
Test 3
Average
Paula
70
85
82
79
Cindy
85
92
90
89
Zach
100
91
96
96
Richie
80
72
66
73
Linda
74
65
81
73
Elisabeth
93
89
94
92
Nate
99
98
93
97
Gigi
100
78
92
90
Billy
61
67
56
61
Ginger
72
83
86
80
Ted
76
93
98
89
Jack
58
76
53
62
Results
=IF(E2>=85,"A",IF(E2>=75,"B",IF(E2>=63,"C","Fail")))
=IF(AVERAGE(B2,C2,D2)>85,"A",IF(AVERAGE(B2,C2,D2)>73,"B",IF(AVERAGE(B2,C2,
D2)>=63,"C","Fail")))
IF function
Use the IF function, one of the logical functions, to return one value if a condition is true and
another value if it's false.
Syntax
IF(logical_test, value_if_true, [value_if_false])
For example:
=IF(A2>B2,"Over Budget","OK")
=IF(A4=500,B4-A4,"")
Argument name
Description
logical_test
(required)
The condition you want to test. You can nest other logical functions within
this argument, including AND, OR and XOR functions.
value_if_true
(required)
The value that you want returned if the result of logical_test is TRUE.
value_if_false
(optional)
The value that you want returned if the result of logical_test is FALSE.
Examples
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet.
To see the formula in a formula cell, select the cell and press F2.
Actual Expense
Predicted Expense
$1,500
$900
$500
$900
$500
$925
=IF(A2>B2,"Over
Budget","OK")
=IF(A2<B2,TRUE,
IF(A3>B3,"over
budget","OK"))
=IF(A4=500,B4-A4,"")
=IF(A2<B2,TRUE,
IF(A3>B3,"over
budget","OK"))
Sales Rep
Paul Wilder
Expecte
Actua
Actual Expecte
d
l
Expense d Flight
Expense
Flight
s
Cost
s
Cost
$1,500
$900
$400
$700
Angela Smith
$500
$900
$800
$1700
Bill Jackson
$500
$925
$600
$900
Lily Payton
$1300
$800
$1200
$900
Von Miller
$2200
$7300
$400
$3000
Jenny Wilson
$700
$1050
$700
$600
=IF(AND(C2=<B2,E2<=D2),"Approve","Audit")
=IF(AND(C2<=B2,E2<=D2),"Approve", IF(C2
>=5000,"Flag for Excess","Audit"))
=IF(AND(C2<=B2,E19<=D19),"Approve",IF(C1>=5000,
(A2&" "&"has incurred excessive spending"),"Audit"))
When Excel finishes evaluating the first condition, the results may match (in which case the
Approve result appears) or they may not. If it's not a match, the parent IF function has already
run through two of its three arguments. You still have two possible outcomes! You complete your
formula by nesting your second IF function in the third argument (value_if_false) of the parent
IF. The nested IF becomes the self-contained third argument of the parent IF. When the nested IF
finishes evaluating, it decides between the two remaining possible outcomes, displays the result,
and the function ends.
In this example, you see the use of nested IFs in a popular application of exam grading averages.
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet.
Place your formula in the far right Results column starting in Row 2, cell F2. To see the formula
in a formula cell, select the cell and press F2.
Student
Test1
Paula
70
85
82
79
Cindy
85
92
90
89
Zach
100
91
96
96
Richie
80
72
66
73
Linda
74
65
81
73
Elisabeth
93
89
94
92
Nate
99
98
93
97
Gigi
100
78
92
90
Billy
61
67
56
61
Ginger
72
83
86
80
Ted
76
93
98
89
Jack
58
76
53
62
Results
Meeting Date
Planning 1
10-Jan
Planning 2
17-Jan
Design 1
24-Jan
Design 2
31-Jan
Design 3
6-Feb
Meeting Status
Design 4
13-Feb
Review 1
20-Feb
Review 2
27-Feb
=IF(B2<=DATEVALUE("2/6/2016"),
"Finished", "Upcoming")
Common Problems
Problem
In all Excel IF functions, the THEN is always implied. You do not explicitly
state a THEN argument in any IF formula; the logical_test argument, and
Where's the THEN
any nested IFs in value_if_true or value_if_False arguments imply the
function? Is there
"Then" actions. In the same way, Excel does not support an ELSE function.
an ELSE function?
ELSE is implied by the three arguments of the IF function (IF logical_test,
then value_if_true, else value_if_False.
0 (zero) in cell
#NAME? in cell
Problem
#VALUE! in cell
If none of the arguments in the function evaluate to a logical value, for the
logical_test, value_if_true or value_if_False arguments, you will receive a
#VALUE! error. This can occur if you make mistakes in defining your
arguments.
Best practices
Do this
Why
Carefully consider
when using IF
functions within
another IF.
If any of the arguments to the IF function are arrays, every element of the
Use IF with arrays array is evaluated when the IF statement is carried out. Learn how to create
an array formula.