Students use IF to make a cell decide between two answers and COUNTIF to count the cells that match a rule, both following when a number changes. They sort eight Year 7 bean heights into Tall and Short and count each group, then do the same for quiz scores, and repeat it in the spreadsheet app the school uses.
Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
WorksheetOpen in PrintDownload Print the student copy; the Teacher edition has the answers.
Students will be able to
I can write an IF with a test and two answers.
I can use COUNTIF to count the cells that match a rule.
I can say when a quote mark is needed.
Timing
Predict and Try 8 min · Worked example 10 min · Vary 7 min · Practise 10 min · Make and own app 10 min
Before class
Do the Try board yourself: change B2 and watch C2, then B11.
The one idea: IF lets a cell make a decision from other cells, and COUNTIF counts how many cells meet a rule. Both are formulas, so they work again when a number changes.
Comparison signs: = (equal), <> (not equal), > (more than), < (less than), >= (more than or equal), <= (less than or equal). A test using > leaves out the boundary value, which is a common slip: the boundary question in Vary is there for it.
Quote marks: words in a formula go in quotes. The sheet on the page shows #NAME? without them, as Excel and Sheets do. COUNTIF's rule is also in quotes (">=10", "Tall"), and does not mind capital letters.
Real tools: some offer smart quotes when pasted from a document, which breaks formulas. Type the quotes in the cell itself.
Running the lesson
Predict: students who chose 4 think the count was fixed. Ask what C2 would show now and who changes it.
Try: ask which cell changed first, C2 or B11, and why.
Worked example: say the IF aloud as a sentence and ask what each comma separates.
Practise: ask what the count would be if the rule were >10, and why Bean B changes sides.
Own app: walk round. Common slips: missing quotes, a missing bracket, and > where >= was meant.
In class
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
Think, pair, share(start) The scientist calls a bean Tall at 10 cm or more. A friend says 9 cm should be Tall. Who is right, and what changes in the sheet?
How many formulas does each person change?
Does the count change? Does the data?
Neither is wrong: the cut-off is a choice. It is also a good reason to put the cut-off in its own cell and fix it with $, so changing the choice means changing one number (the previous lesson's idea).
Human IF(predict, 3 min)
Hold up cards with heights (8.5, 10, 12, 7). Students stand if they would be Tall under the rule 'Tall is 10 or more' and sit if not. Count the standing.
That is exactly what IF does for each cell and COUNTIF does for the room.
Where is the cut-off?(make, 4 min)
Why 10 cm? Who decides where Tall starts? What would change if we chose 9 or 11?
The sheet only follows the rule it is given. People choose the rule. Useful for any grading cut-off.
Which sign?(investigate) B2 holds 10. Which test is true? B2>=10 >= means more than or equal, so 10 passes. > and < leave out 10, and <> means not equal.
The hard part (on purpose)
Writing the three parts of IF in the right order, with words in quotes. Students who have never written a formula with commas find it fiddly: let them say it aloud first (if this, then that, otherwise this).
When students get stuck
What you will see
A question to ask
The fix
A student leaves the quote marks off Tall and Short (Sam's mistake).
What does the sheet think Tall is, if it is not in quotes?
Put quote marks around each word.
A student writes > where >= was needed and Bean B comes out Short.
Is 10 more than 10? Which sign includes 10?
Use >= to include the boundary.
A student's COUNTIF shows 0.
Does the rule match what is in the cells, including the quote marks?
Check the spelling of the word and that the rule is in quotes.
A student's IF shows TRUE or FALSE.
How many parts does your IF have? Where are the two answers?
Write =IF(test, answer if true, answer if not).
Answers to the checks
what happens to the count?: 4 beans are Tall, so B11 shows 4. Bean A in B2 is 8.5, so C2 shows Short. B2 is changed to 10.5. What does B11 show? 5. C2's IF now sees 10.5, which is 10 or more, so C2 shows Tall. COUNTIF counts one more Tall plant.
Try: change a height: Change Bean A's height in B2 to 10.5. What does the count of Tall plants in B11 show?
B11 shows 5. C2 now says Tall, so COUNTIF finds 5 Tall plants instead of 4.
IF and COUNTIF: What does =IF(B2>=10,"Tall","Short") show when B2 holds 12? Tall The test B2>=10 is true for 12, so IF shows its first answer, Tall.
Find the mistake: Sam's C2 shows #NAME? instead of Tall or Short. Click the line where Sam first goes wrong. line 2 Line 2: Tall and Short are words, so they need quote marks. Without them, the sheet thinks Tall is the name of something and shows #NAME?.
Count the cells: What does =COUNTIF(B2:B9,">=10") count? How many cells from B2 to B9 hold 10 or more COUNTIF counts the cells in the range that match the rule in quotes.
Count the tall ones: The heights are 8.5, 10, 9.5, 12, 11, 9, 13.5 and 7. What does =COUNTIF(B2:B9,">=10") show? 4 The cells with 10 or more are 10, 12, 11 and 13.5: 4.
The boundary: B2 holds exactly 10. What does =IF(B2>10,"Tall","Short") show? Short > means more than, so 10 is not enough. >= means more than or equal, and would have given Tall.
Choose the formula: You want C2 to say Healthy if the height in B2 is more than 8, and Check if not. Which formula do you write? =IF(B2>8,"Healthy","Check") Test first (B2>8), then the answer if true, then the answer if not, with words in quote marks.
What happens to the count?: Every bean has a Tall or Short answer in column C, and B11 counts the Tall ones. Bean F in B7 grows from 9 to 10.5. What happens to the count in B11? It goes up by one Bean F becomes Tall, so there is one more Tall plant to count.
Write the IF: Write an IF formula in C2 that says Tall for 10 or more and Short if not. Fill it down to C9.
Each C cell holds an IF such as =IF(B5>=10,"Tall","Short"). B11 counts 4 Tall plants.
Count the other way: The sizes are filled in. In B12, count how many plants are shorter than 9 cm.
B12 holds =COUNTIF(B2:B9,"<9"): the heights 8.5 and 7 are under 9, so the count is 2.
a quiz result: Type eight quiz scores, some under 5 and some 5 or more. Write an IF in C2 (5 or more is Pass, otherwise Retry) and fill it down. Count the Pass cells in B11 and the Retry cells in B12.
Column C decides with IF, B11 holds =COUNTIF(C2:C9,"Pass") and B12 holds =COUNTIF(C2:C9,"Retry"). Together they count all eight scores.
Solutions
One possible solution for each task. Other correct programs are fine.
a quiz result
Open task: any program that does what the step asks.
Stretch and support
Stretch: Add a third group, Very tall, for 12 cm or more. Which function lets one IF choose between three answers? (Hint: put an IF inside an IF.)
Support: A card: =IF(test, answer if true, answer if not). Words go in "quotes". >= means 10 or more; > means more than 10.
Exit ticket
B2 holds 7. What does =IF(B2>=10,"Tall","Short") show? And what would it show if B2 were 10?
Short for 7, and Tall for 10, because >= includes 10.
What each step is for
what happens to the count?: Committing to what the count shows after one height changes tests the move: IF and COUNTIF both work again from the new number.
Try: change a height: Changing B2 and watching C2 and B11 settles the prediction: IF decides again, then COUNTIF counts again.
Worked example: decide, then count: Writing the test and the two answers models the move. Sam leaves the quote marks off the words, the mistake planted after the method.
Vary: change the test: Each task changes the rule: a number test, a test on the boundary, then words for the answers.
decide and count: Writing an IF column and a COUNTIF, and counting the other way round.
a quiz result: Building a pass or retry column and two counts for a quiz of their own has students use IF and COUNTIF on their own data.
In your own spreadsheet app: Using IF and COUNTIF in Excel or Sheets shows the same two functions in the real tool.
Where it leads
Next in Working with data: Put the rows in order (sort and filter).
Science: sorting measurements into groups (tall and short, healthy and not) is the first step to comparing them. A cut-off such as 10 cm is a choice: ask students why that one.