← Teacher guide

Count and decide

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.

Working with data · Summing up · about 45 minutes · Open the student lesson

Classroom resources

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.

Students will be able to

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

  1. Predict: students who chose 4 think the count was fixed. Ask what C2 would show now and who changes it.
  2. Try: ask which cell changed first, C2 or B11, and why.
  3. Worked example: say the IF aloud as a sentence and ask what each comma separates.
  4. Practise: ask what the count would be if the rule were >10, and why Bean B changes sides.
  5. 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.

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 seeA question to askThe 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

  1. 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.
  2. 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.
  3. 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.
  4. 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?.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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

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.