Sie sind auf Seite 1von 6

BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 4: The IF Funtion – Page 1 of 6

MS EXCEL 2003
THE IF FUNCTION

THE IF FUNCTION

The IF function takes one action if a given condition set is met (condition = true) and a different
action if the same condition is not met (condition = false). The action can be a calculation or
entry of a value or label.
Parts of the IF function
= IF (Condition, X, Y)

X represents the Y represents the


CONDITION sets the action that will be
test or criteria that action that will be
taken if the taken if the
must be met condition is met condition is NOT
(TRUE) met (FALSE)

=IF("if the condition stated here is true", "then enter this value", "else enter this value")

Background Reading
1. The spreadsheet (see below) will calculate the amount of a commission. Sales representatives
will earn 10% commission on sales if their sales are greater than $15,000 and only 7%
commission on sales if their sales are less than or equal to $15,000. The IF function will be used
to calculate the commission figure (commission rate * sales)
CONDITION sales over 15000
TRUE ACTION sales x 10% - to calculate the commission amount
FALSE ACTION sales x 7% - to calculate the commission amount
2. The spreadsheet will enter a comment based upon the sales results.
To use the IF function to enter text into a cell, you must put the text in quotes in the formula.
If the sales amount is greater than or equal to $15,000, the words “Well Done” will be entered into
the cell and if sales are less than $15,000, the words “Good Job” will be entered.
CONDITION sales greater than or equal to 15000
TRUE ACTION “Well Done”
FALSE ACTION “Good Job”

ANSWER – showing formulas


A B C
1 Sales Commission Amount Comment
2 15000 =IF(A2>15000, A2*.1, A2*.07) =IF(A2>=15000, “Well Done”, “Good Job”)
3 20000 =IF(A3>15000, A3*.1, A3*.07) =IF(A3>=15000, “Well Done”, “Good Job”)

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit1: Spreadsheet – Part 3: The IF Function – Page 1
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 4: The IF Funtion – Page 2 of 6

MS EXCEL 2003
THE IF FUNCTION

ANSWER – showing values


A B C
1 Sales Commission Amount Comment
2 15000 $1,050 Well Done
3 20000 $2,000 Well Done

Ex. 1 Using the IF Function


1. Read and review the IF function theory on the previous page.
2. Create the spreadsheet cells of A1:C3 as in the example.
3. Use the IF function to calculate the Commission Amount and record a Comment in
cells B2 & C2.
Reminder: To enter a function into a cell, click on the down arrow next to the
AutoSum button ∑ on the Standard Toolbar. Select More Functions. (The functions
may also be typed in directly from the keyboard.)
4. Copy the functions down to B3 & C3.
5. Save as Excel4_IF_ex1.xls.

Ex. 2 Using the IF function to add a label and calculate a value


1. Enter the spreadsheet values and labels using cells
A1:E6. Format the values and labels as shown.
2. Enter formulas and IF functions to complete the
following:
• If employee’s Gross Pay is greater than or
equal to $31,500, the Income Tax Deduction
is calculated at 25% of Gross Pay. If
employee’s Gross Pay is less than $31,500,
the Income Tax Deduction is calculated at
18% of Gross Pay
• Net Pay equals Gross Pay minus Income Tax Deductions
• If Net Pay is less than $18,000 the comment should read “Below the poverty line”. If Net
Pay is greater than or equal to $18,000 the comment should read “Above the poverty
line”
3. Save as Excel4_IF_ex2.xls.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit1: Spreadsheet – Part 3: The IF Function – Page 2
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 4: The IF Funtion – Page 3 of 6

MS EXCEL 2003
THE IF FUNCTION

Ex. 3 Practice: Customer discount


1. Create a worksheet as illustrated.

2. If the Total (B5) is greater than $500.00, then


a. D4 reads “As a Premium Customer”; otherwise D4 reads “As a Valued
Customer.”
b. D5 reads “you are entitled to a discount of” if B5 is greater than 0
c. D6 reads “25%”; otherwise D6 reads “15%”
3. Test your IF formula by changing some of the values in Column B.
4. Save as Excel4_IF_ex3.xls.

Ex. 4 Practice: Trucking company


You have been hired by a small trucking company to calculate net pay. You have been told to include an
IF function in the spreadsheet. You are to format the spreadsheet using a variety of alignments, fonts and
font effects. The end result must be professionally presented.
1. Create the worksheet for the ABC Trucking Company pay schedule as shown.
2. Enter formulas and functions to
complete the following:
a. Calculate Gross Earnings
b. The deduction amount is
based upon the gross earnings
figure. Deduction are
calculated at 10% if gross
earnings are less than $250 and
12% if gross earnings are $250
or more
c. Calculate Net Pay
3. Create a textbox anywhere on the spreadsheet. Move to cell E4. Copy the IF from the Formula
Bar, and paste it into the textbox. Draw an arrow to the column that includes the IF function.
4. Save as Excel4_IF_ex4.xls.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit1: Spreadsheet – Part 3: The IF Function – Page 3
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 4: The IF Funtion – Page 4 of 6

MS EXCEL 2003
THE IF FUNCTION

Ex. 5 Nesting IF statements

The IF function can be used on its own, but it is often combined with another function. Combining
functions like this is known as nesting. In nested functions, we use the result of one function as input for
another.
1. Create a worksheet with the series of numbers 1 to 10 in
C1:C10.
2. You want B11 to show the sum of the series if the sum is
greater than 50; otherwise, show the highest number of
the series. In B11 enter the formula
=IF(SUM(C1:C10)>50,SUM(C1:C10),MAX(C1:C10)).
3. Test the formula by changing some numbers in the series.
4. Test the formula by changing the 50 in the test condition
5. Test the formula by changing the 50 in the test condition to
nothing (double quotation marks with nothing between “”).
6. Test the formula by changing MAX(C1:C10) to MIN(C1:C10).

Ex. 6 Complex Nested IF functions (or Why We Need the LOOKUP Functions)
Problem: Excessive numbers of nested IF Functions are difficult to manage
Example: =IF(C2=1,100,IF(C2=1,200,IF(C2=2,300,IF(C2=3,400,"Not available"))
Excel allows no more than 7 nested IF functions. Nested IF functions can quickly get very complicated, so
Excel offers other functions to handle such tasks more efficiently, namely, the LOOKUP functions. This
exercise gives you the horrible experience of using moderately complex nested IF functions so that you
understand the need for alternatives.
Imagine you are converting student marks from percentages to letter grades according to the following
scheme:
A 80 to 100
B 70 to 79
C 60 to 69
D 50 to 59
F 0 to 49
1. Enter student marks in a worksheet named Excel4_IF_ex6.xls as illustrated.
2. In B1 enter this formula of nested IF functions:
=IF(A1>79,”A”,IF(A1>69,”B”,IF(A1>59,”C”,IF(A1>49,”D”, IF(A1>0,”F”)))))
3. Use the fill handle (the small black cross that appears when your cursor is
placed at the bottom right corner of the cell) to copy the formula down to
A1:A10.
As you can see, although nested IF functions work, they can become quite difficult to set up.
Also, the limit of 7 is sometimes too restricting.
Rather than complicated nested IF functions, you should use the VLOOKUP function, which you
will learn about in the next unit.

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit1: Spreadsheet – Part 3: The IF Function – Page 4
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 4: The IF Funtion – Page 5 of 6

MS EXCEL 2003
THE IF FUNCTION

Enrichment
The section below is for students who have finished their work before the rest of the class. It will give you
a higher level of expertise with Microsoft Word 2003.
This material will not appear on tests.

Ex. 7 COUNTIF
Similar to the IF function are the functions COUNTIF and SUMIF. All 3 functions can be used to
analyze data based on a condition.
COUNTIF counts the number of non-blank cells in a range that
meet given criteria.
1. Create the worksheet as illustrated.
2. In D13 enter the Countif function with the range B1:B12 and the
criteria <6.50.
3. Cell D13 displays the number of cells in the range B1:B12
containing values less than 6.50.

Ex. 8 SUMTIF

SUMIF adds all numbers in a range of cells, based on a given criteria.


=SUMIF( range, criteria, sum_range )
range is the range of cells that you want to apply the criteria against.
criteria is used to determine which cells to add.
sum_range are the cells to sum.
1. In a new worksheet enter figures in A1:A4 as illustrated to represent
property values for 4 homes and in B1:B4 to represent sales
commissions at 6%.
2. You want to calculate total commissions for homes which sold for over
$160,000. In C1 enter the formula =SUMIF(A1:A4,">160000",B1:B4)
3. The result in C1 is 54,000.
4. Save as Excel4_IF_ExF.xls.
5. The result in C1 is 54,000.
6. Save as Excel4_IF_ExF.xls.
SUMIF applies the criteria >160000 to cells in the range A1:A4. If a cell meets the criteria, the
corresponding cell in the range B1:B4 is summed.
7. Using the same worksheet, you want to see how many commissions were under $20,000.
8. In D1 enter the formula =COUNTIF(B1:B4,">20000")

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit1: Spreadsheet – Part 3: The IF Function – Page 5
BTA3O1 – Productivity Software – Unit 2: Spreadsheet – Part 4: The IF Funtion – Page 6 of 6

MS EXCEL 2003
THE IF FUNCTION

9. The result in D1 is 1.
Another set of data for practising SUMIF:
10. In Sheet 2 enter data as illustrated.
11. Experiment with the SUMIF functions listed below:
Formula R

=SumIf(A2:A6, D2, C2:C6) 2

=SumIf(A2:A6, 2003, 7
C2:C6)
=SumIf(A2:A6, ">=2001", 1
C2:C6)

To summarize –
SUMIF
Adds the cells specified by given criteria.
SUMIF(range,criteria,sum_range)
Range is the range of cells you want evaluated.
Criteria is the criteria in the form of a number, expression, or text that defines which cells
will be added. For example, criteria can be expressed as 32, "32", ">32", "apples".
Sum_range are the actual cells to sum. The cells in sum_range are summed only if their
corresponding cells in range match the criteria. If sum_range is omitted, the cells in
range are summed.

COUNTIF
Counts the number of cells within a range that meet given criteria.
COUNTIF(range,criteria)
Range is the range of cells from which you want to count cells.
Criteria is the criteria in the form of a number, expression, or text that defines which cells
will be counted. For example, criteria can be expressed as 32, "32", ">32", "apples".

BTA3O1 Information and Communication Technology: The Digital Environment- Productivity Software
Unit1: Spreadsheet – Part 3: The IF Function – Page 6

Das könnte Ihnen auch gefallen