IF Function

You might also like

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 11

IF and Nested IF In the following table mark

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
to be
be TRUE.
TRUE. If
If the
the condition
condition is
is not
not met
met it
it is
is considered
considered as
as FALSE.
FALSE. Marks
Depending
Depending upon
upon the
the result,
result, one
one of
of two
two actions
actions will
will be
be carried
carried out.
out. >=75
>50 and <75
Syntax
Syntax
IF(logical_test,value_if_true,value_if_false) <=50
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
her grade the students as follows-

Grade
A
B
C

Marks Result Grade


50
60
80
75
10
98
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
12099 26-Nov-17 10,000.00
11045 14-Nov-17 7,000.00
10001 23-Oct-17 5,000.00
11000 24-Nov-17 4,350.00
13003 4-Dec-17 2,000.00
12001 17-Oct-17 2,000.00
Total

* Note that each invoice will fall in only one of the two columns.
he no. of days
Today's Date 12/14/2017
Student Gender Score Pass/Fail Letter Outlier
Jill F 90
Tom M 80
Brittany F 96
Alan M 72
George M 69
Sally F 52
Chris M 99
Jamie F 82
Valorie F 67
Steve M 90
Jake M 83
Lori F 89
Meghan F 60
Michelle F 63
Tim M 59

Bonus points if you don't use AND statements!


Award
INSTRUCTIONS:
INSTRUCTIONS:
1)
1) Populate
Populate column
column DDtoto return
return "PASS"
"PASS" ifif the
thescore
scorein
incolumn
columnCC isis
greater
greater than
than or
or equal
equal to
to 60,
60, otherwise
otherwise return
return"FAIL"
"FAIL"
2)
2) Populate
Populate column
column EEto to return
return aaletter
letter grade
gradebased
based on
on the
the score
score in
in
column
column C,
C, using
using the
the logic
logic below:
below:
AA ==>=90
>=90
BB ==80-89
80-89
CC == 70-79
70-79
DD ==60-69
60-69
FF ==<60
<60
3)
3) Populate
Populate column
column FF to
to return
return "OUTLIER"
"OUTLIER" ifif the
thescore
scorein
in column
columnCC isis
either
either <60
<60 or
or >90,
>90, otherwise
otherwise return
return"AVG"
"AVG"
4)
4) Populate
Populate column
column GG to
to return
return"Male
"Male Achiever"
Achiever" ifif Gender
Gender ==MM and
and
the
the score
score in
in column
column CCisis >95,
>95, "Female
"Female Achiever"
Achiever" ifif Gender
Gender == FF and
and
the
the score
score in
in column
column CCisis >95,
>95, otherwise
otherwise "None"
"None"
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
false, expression1 is the value of the formula if the condition is true, and expression2 is the value of the formula i 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
numer
value), itit should
value), should be
be enclosed
enclosed in
in double
double quotes.
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 on
on whether
whether the
the val
val
in cell A1 is negative, zero, or positive. A nested IF formula can then be used as follows.
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,
negative number, B2B2 contains
contains 10.
10. Otherwise,
Otherwise, ififA1
A1 contains
contains 0,0, B2
B2 contains
contains 20.20. Otherwise
Otherwise (meaning
(meaning that
thatA1
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.)
mplex. II will
mplex. 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

y condition
condition that
that isis either
either true
true or
or Product End inventory Order placed (yes or no)?
n2 is the value of the formula ifif
n2 is the value of the formula 1 100
2 40
3 20
a label
label (as
(as opposed
opposed to
to aa numeric
numeric
4 70

e the
the answer.)
answer.)

depending on
depending on whether
whether the
the value
value
llows.
lows. 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

sion3)).
ion3)). IfIf condition1
condition1 isis true,
true, the
the Student Score Grade
evant value is expression2.
evant value is expression2. 1 70
2 95
ell B2.
B2. Then
Then ififA1
A1 contains
contains aa 3 55
ell
erwise (meaning
erwise (meaning that
thatA1
A1 must
must 4 80
5 60
6 90
tt to
to see
see the
the answer.)
answer.)
an or equal to 50 units,
p to 200; otherwise, no

# of units ordered
-
-
-
-

), S for satisfactory (if score


sfactory 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:
483 gallons:
500 gallons:
1600 gallons:

You might also like