Beruflich Dokumente
Kultur Dokumente
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)
=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”
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
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
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
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
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, 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