0% found this document useful (0 votes)
150 views5 pages

IF Function: Evaluated To TRUE or False

The IF function in Excel returns one value if a condition is TRUE and another value if it is FALSE. It has three arguments: a logical test, a value if TRUE, and a value if FALSE. The function can be nested up to 64 times to construct more complex tests. It is commonly used to return text based on a cell value meeting certain criteria, but other functions like LOOKUP can also evaluate multiple conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views5 pages

IF Function: Evaluated To TRUE or False

The IF function in Excel returns one value if a condition is TRUE and another value if it is FALSE. It has three arguments: a logical test, a value if TRUE, and a value if FALSE. The function can be nested up to 64 times to construct more complex tests. It is commonly used to return text based on a cell value meeting certain criteria, but other functions like LOOKUP can also evaluate multiple conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

IF function

This article describes the formula syntax and usage of the IF function in Microsoft Excel.
Description
The IF function returns one value if a condition you specify evaluates to TRUE, and
another value if that condition evaluates to FALSE. For example, the formula
=IF(A1>10,"Over 10","10 or less") returns "Over 10" if A1 is greater than 10, and "10
or less" if A1 is less than or equal to 10.
Syntax
IF(logical_test, [value_if_true], [value_if_false])
The IF function syntax has the following arguments.
Logical_test Required. Any value or expression that can be evaluated to TRUE
or FALSE. For example, A10=100 is a logical expression; if the value in cell A10 is
equal to 100, the expression evaluates to TRUE. Otherwise, the expression
evaluates to FALSE. This argument can use any comparison calculation operator.
Value_if_true Optional. The value that you want to be returned if the
logical_test argument evaluates to TRUE. For example, if the value of this
argument is the text string "Within budget" and the logical_test argument
evaluates to TRUE, the IF function returns the text "Within budget." If logical_test
evaluates to TRUE and the value_if_true argument is omitted (that is, there is
only a comma following the logical_test argument), the IF function returns 0
(zero). To display the word TRUE, use the logical value TRUE for the value_if_true
argument.
Value_if_false Optional. The value that you want to be returned if the
logical_test argument evaluates to FALSE. For example, if the value of this
argument is the text string "Over budget" and the logical_test argument
evaluates to FALSE, the IF function returns the text "Over budget." If logical_test
evaluates to FALSE and the value_if_false argument is omitted, (that is, there is
no comma following the value_if_true argument), the IF function returns the
logical value FALSE. If logical_test evaluates to FALSE and the value of the
value_if_false argument is blank (that is, there is only a comma following the
value_if_true argument), the IF function returns the value 0 (zero).
Remarks

Up to 64 IF functions can be nested as Value_if_true and Value_if_false


arguments to construct more elaborate tests. (See Example 3 for a sample of
nested IF functions.) Alternatively, to test many conditions, consider using the
LOOKUP, VLOOKUP, HLOOKUP, or CHOOSE functions. (See Example 4 for a
sample of the LOOKUP function.)
If any of the arguments to IF are arrays, every element of the array is evaluated
when the IF statement is carried out.
Excel provides additional functions that can be used to analyze your data based
on a condition. For example, to count the number of occurrences of a string of
text or a number within a range of cells, use the COUNTIF or the COUNTIFS
worksheet functions. To calculate a sum based on a string of text or a number
within a range, use the SUMIF or the SUMIFS worksheet functions.
Examples
Copy the example data in the following table, and paste it in cell A1 of a new Excel
worksheet. For formulas to show results, select them, press F2, and then press Enter. If
you need to, you can adjust the column widths to see all the data..
Data
50

23

33175

Formula

Description

Result

=IF(A2<=100,"Within
budget","Over budget")

If the number in cell A2 is less than or equal


to 100, the formula returns "Within budget."
Otherwise, the function displays "Over
budget."

Within
budget

=IF(A2=100,A2+B2,"")

If the number in cell A2 is equal to 100, A2 +


B2 is calculated and returned. Otherwise,
empty text ("") is returned.

=IF(3<1,"OK")

If the result is False and no value_if_false


argument is provided for the False result,
FALSE is returned.

FALSE

If the result is False and a blank


value_if_false argument is provided for the
False result (a comma follows the
value_if_true argument), 0 is returned.

EXAMPLE 2
Actual Expenses

Predicted Expenses

$1,500

$900

$500

$900

$500

$925

Formula

Description

Result

=IF(A2>B2,"Over
Budget","OK")

Checks whether actual expenses in row 2 are


greater than predicted expenses. Returns "Over
Budget" because the result of the test is True.

Over
Budget

=IF(A3>B3,"Over
Budget","OK")

Checks whether actual expenses in row 3 are


greater than predicted expenses. Returns "OK"
because the result of the test is False.

OK)

EXAMPLE 3
Score
45
90
78
Formula

Description

Result

=IF(A2>89,"A",IF(A2>79,"B",
IF(A2>69,"C",IF(A2>59,"D","F"))))

Uses nested IF conditions to


assign a letter grade to the
score in cell A2.

=IF(A3>89,"A",IF(A3>79,"B",
IF(A3>69,"C",IF(A3>59,"D","F"))))

Uses nested IF conditions to


assign a letter grade to the
score in cell A3.

=IF(A4>89,"A",IF(A4>79,"B",
IF(A4>69,"C",IF(A4>59,"D","F"))))

Uses nested IF conditions to


assign a letter grade to the
score in cell A4.

EXAMPLE 4
Score
45
90
78
Formula

Description

=LOOKUP(A2,{0,60,63,67,70,73,77,80,83,87,90,93,97},{"F","D","D","D+","C-","C","C+","B-","B","B+","A-","A","A+"})

Instead of
using
multiple
nested IF
functions, the
formula uses
the LOOKUP
function to
find a letter
grade that
corresponds
to a numeric

Result
F

score stored
in an array in
the formula.
=LOOKUP(A3,{0,60,63,67,70,73,77,80,83,87,90,93,97},{"F","D","D","D+","C-","C","C+","B-","B","B+","A-","A","A+"})

Instead of
using
multiple
nested IF
functions, the
formula uses
the LOOKUP
function to
find a letter
grade that
corresponds
to a numeric
score stored
in an array in
the formula.

A-

=LOOKUP(A4,{0,60,63,67,70,73,77,80,83,87,90,93,97},{"F","D","D","D+","C-","C","C+","B-","B","B+","A-","A","A+"})

Instead of
using
multiple
nested IF
functions, the
formula uses
the LOOKUP
function to
find a letter
grade that
corresponds
to a numeric
score stored
in an array in
the formula.

C+

You might also like