You are on page 1of 10

IF and Nested IF In the following table mark P

Further grade the students as


This
This function
function tests
tests aa condition.
condition. If
If the
the condition
condition is
is met
met it
it is
is
considered
considered to be TRUE. If the condition is not met it is considered
to be TRUE. If the condition is not met it is considered Marks
as
as FALSE.
FALSE. Depending
Depending uponupon the
the result,
result, one
one of
of two
two actions
actions will
will be
be >=75
carried out.
carried out. >50 and <75
<=50
Syntax
Syntax
IF(logical_test,value_if_true,value_if_false)
IF(logical_test,value_if_true,value_if_false) Name
A
B
C
D
E
F
he following table mark Pass if marks greater than 50. Otherwise mark fail in result column
ther grade the students as follows-

Grade
A
B
C

Marks Result Grade


50 FAIL C
60 PASS B
80 PASS A
75 PASS A
10 FAIL C
98 PASS A
IF FUNCTION
(1) Compute the no. of days overdue for each invoice as on date.
(2) Then compute the respective amounts in each of the two amount columns based on the no. of days
and compute the total amount due upto 30 days and over 30 days

Due Date of Amount No. of days Amount Amount


Invoice No. Invoice Outstanding overdue Upto 30 days Above 30 days
14123 15-Oct-17 50,000.00 60 - 50,000.00
12099 26-Nov-17 10,000.00 18 10,000.00 -
11045 14-Nov-17 7,000.00 30 7,000.00 -
10001 23-Oct-17 5,000.00 52 - 5,000.00
11000 24-Nov-17 4,350.00 20 4,350.00 -
13003 4-Dec-17 2,000.00 10 2,000.00 -
12001 17-Oct-17 2,000.00 58 - 2,000.00
80,350.00 Total 23,350.00 57,000.00

* Note that each invoice will fall in only one of the two columns.
n the no. of days
Today's Date 12/14/2017
WE HAVE TO USE EITHER F4 OR $ SIGN FOR NUMBER OF DAYS
IF functions
IF functions are
are very
very useful
useful for
for performing
performing logic,
logic, and
and they
they vary
vary from
from simple
simple to
to complex.
complex. II will
will provide
provide aa few
few
examples.
examples.

To enter
To enter aa basic
basic IF
IF function:
function:

Enter the
Enter the formula
formula =IF(condition,expression1,expression2),
=IF(condition,expression1,expression2), wherewhere condition
condition isis any
any condition
condition that
that isis either
either true
true or
o
false, expression1 is the value of the formula if the condition is true, and expression2 is the value of the formula ii
false, expression1 is the value of the formula if the condition is true, and expression2 is the value of the formula
the condition
the condition isis false.
false.

Asimple
A simple example
example isis =IF(A1<5,10,“NA”).
=IF(A1<5,10,“NA”). Note
Note that
that ifif either
either of
of the
the expressions
expressions isis aa label
label (as
(as opposed
opposed to
to aa numeri
numeri
value), it should be enclosed in double quotes.
value), it should be enclosed in double quotes.

Try it!
Try it! Enter
Enter appropriate
appropriate IF
IF formulas
formulas in
in columns
columns CC and
and D.
D. (Scroll
(Scroll to
to the
the right
right to
to see
see the
the answer.)
answer.)

Sometimes IF
Sometimes IF functions
functions are
are nested.
nested. For
For example,
example, there
there might
might be
be three
three possibilities,
possibilities, depending
depending onon whether
whether the
the
value in cell A1 is negative, zero, or positive. A nested IF formula can then be used as follows.
value in cell A1 is negative, zero, or positive. A nested IF formula can then be used as follows.

To use
To use nested
nested IF
IF functions:
functions:

Enter the
Enter the formula
formula =IF(condition1,expression1,IF(condition2,expression2,expression3)).
=IF(condition1,expression1,IF(condition2,expression2,expression3)). IfIf condition1
condition1 isis true,
true, th
th
relevant value is expression1. Otherwise, condition2 is checked. If it is true, the relevant value is expression2.
relevant value is expression1. Otherwise, condition2 is checked. If it is true, the relevant value is expression2.
Otherwise, the
Otherwise, the relevant
relevant value
value isis expression3.
expression3.

An example
An example isis =IF(A1<0,10,IF(A1=0,20,30)).
=IF(A1<0,10,IF(A1=0,20,30)). Suppose
Suppose this
this formula
formula isis entered
entered in
in cell
cell B2.
B2. Then
Then ififA1
A1 contains
contains aa
negative number, B2 contains 10. Otherwise, if A1 contains 0, B2 contains 20. Otherwise (meaning
negative number, B2 contains 10. Otherwise, if A1 contains 0, B2 contains 20. Otherwise (meaning that A1 that A1 must
must
contain aa positive
contain positive value),
value), B2
B2 contains
contains 30.
30.

Try it!
Try it! Use
Use aa nested
nested IF
IF function
function to
to fill
fill in
in the
the grades
grades in
in column
column C.
C. (Scroll
(Scroll to
to the
the right
right to
to see
see the
the answer.)
answer.)
omplex. II will
omplex. will provide
provide aa few
few For each product, if the end inventory is less than or equal to 50 units,
enough units are ordered to bring stock back up to 200; otherwise, no
units of that product are ordered

Product End inventory Order placed (yes or no)?


ny condition
ny condition that
that isis either
either true
true or
or 1 100 NO
on2 is the value of the formula ifif
on2 is the value of the formula
2 40 YES
3 20 YES
s aa label
label (as
(as opposed
opposed to
to aa numeric
numeric 4 70 NO
0

ee the
ee the answer.)
answer.)

es, depending on
s, depending on whether
whether the
the
ed as follows.
d as follows. Each student gets an A (if score is 90 or above), S for satisfactory (if score
if 60 or above but less than 90) or U for unsatisfactory if score is below 60

Student Score Grade


ssion3)). IfIf condition1
ssion3)). condition1 isis true,
true, the
the 1 70 S
elevant value is expression2.
elevant value is expression2. 2 95 A
3 55 U
cell B2.
cell B2. Then
Then ififA1
A1 contains
contains aa 4 80 S
therwise (meaning that
herwise (meaning that A1 A1 must
must 5 60 U
6 90 A

ght to see
ht to see the
the answer.)
answer.)
han or equal to 50 units,
up to 200; otherwise, no

# of units ordered
-
160
180
-

), S for satisfactory (if score


isfactory if score is below 60
Cost/ gallon for the first 500 gallons ₹ 23.00
Cost/ gallon for gallons above 500: ₹ 20.00
Number of gallons:
10
483
500
1600
Use IF formula to calculate the cost of :
10 gallons: ₹ 230
483 gallons: ₹ 11,109
500 gallons: ₹ 11,500
1600 gallons:

You might also like