Cellwise

Unit 5 of 12

Conditional math

Count and sum only what matches.

Functions in this unit: COUNTIF, SUMIF, AVERAGEIF, SUMIFS, COUNTIFS

Key ideas

COUNTIF counts matches

=COUNTIF(B2:B7,"East")

A range to check, then the condition. Matching ignores upper and lower case.

Conditions are text

">=100"

Comparisons go inside quotes. To use a cell value: ">"&F1.

SUMIFS puts the sum range first

=SUMIFS(C2:C7,B2:B7,"East")

SUMIF has the sum range last. SUMIFS has it first. A classic gotcha.

Lesson 1: COUNTIF

  1. How many products sell in the East region? Put the count in F2.

    ABCDEF
    1ProductRegionUnitsPriceEast count
    2NotebookEast1203.5
    3PenWest3401.25
    4StaplerEast4512
    5BinderNorth806.75
    6MarkerWest2102.4
    7FolderNorth1501.9

    Hint: =COUNTIF(B2:B7,"East")

    Show answer

    =COUNTIF(B2:B7,"East") in F2. COUNTIF checks each cell in the range against your condition.

  2. What will B1 show?

    AB
    140
    275
    351
    450
    5n/a

    B1 contains =COUNTIF(A1:A5,">50")

    Show answer

    2. 75 and 51 are greater than 50. 50 itself is not.

  3. Build: count products with 100 or more units

    Show answer

    =COUNTIF(C2:C7,">=100"). Comparison conditions must be inside quotes.

  4. Why does ">=100" need quotes in COUNTIF?

    • The condition is passed as text that COUNTIF reads
    • Quotes make it faster
    • Numbers always need quotes
    • It does not need quotes
    Show answer

    The condition is passed as text that COUNTIF reads. COUNTIF parses the text to find the operator and the value.

  5. F1 holds a region name. Count how many products are in that region, in F2.

    ABCDEF
    1ProductRegionUnitsPriceRegionWest
    2NotebookEast1203.5Count
    3PenWest3401.25
    4StaplerEast4512
    5BinderNorth806.75
    6MarkerWest2102.4
    7FolderNorth1501.9

    Hint: Use F1 as the condition instead of typing the region.

    Show answer

    =COUNTIF(B2:B7,F1) in F2. Pointing at an input cell turns your formula into a mini tool.

Lesson 2: SUMIF and AVERAGEIF

  1. Total the units sold in the West region, in F2.

    ABCDEF
    1ProductRegionUnitsPriceWest units
    2NotebookEast1203.5
    3PenWest3401.25
    4StaplerEast4512
    5BinderNorth806.75
    6MarkerWest2102.4
    7FolderNorth1501.9

    Hint: =SUMIF(where to check, what to match, what to add)

    Show answer

    =SUMIF(B2:B7,"West",C2:C7) in F2. Pen (340) plus Marker (210) is 550.

  2. What is the average Score for the Sales department? Put it in F2.

    ABCDEF
    1NameDeptScoreHoursSales avg
    2AvaSales9442
    3BenSupport8138
    4CaraSales8845
    5DevOps9736
    6EvaSupport9141
    7FinnOps7344

    Hint: Same shape as SUMIF, just a different function.

    Show answer

    =AVERAGEIF(B2:B7,"Sales",C2:C7) in F2. Ava (94) and Cara (88) average to 91.

  3. In =SUMIF(B2:B7,"West",C2:C7), what is C2:C7?

    • The cells to add up
    • The cells to check
    • The condition
    • The output cell
    Show answer

    The cells to add up. SUMIF(range, criteria, sum_range). The sum range is last.

  4. Build: total hours for the Ops department

    Show answer

    =SUMIF(B2:B7,"Ops",D2:D7). Check the Dept column, add the Hours column.

  5. What will C1 show?

    ABC
    1Tea3
    2Coffee5
    3Tea4

    C1 contains =SUMIF(A1:A3,"Tea",B1:B3)

    Show answer

    7. Only the Tea rows are added: 3 + 4.

Lesson 3: Multiple conditions

  1. Where does the sum range go in SUMIFS?

    • First
    • Last
    • Second
    • Anywhere
    Show answer

    First. SUMIFS(sum_range, range1, criteria1, ...). Opposite of SUMIF.

  2. Total units for East products priced above $5. Put the answer in F2.

    ABCDEF
    1ProductRegionUnitsPriceEast > $5
    2NotebookEast1203.5
    3PenWest3401.25
    4StaplerEast4512
    5BinderNorth806.75
    6MarkerWest2102.4
    7FolderNorth1501.9

    Hint: =SUMIFS(C2:C7, B2:B7, "East", D2:D7, ">5")

    Show answer

    =SUMIFS(C2:C7,B2:B7,"East",D2:D7,">5") in F2. Only the Stapler (45 units at $12) matches both.

  3. Count Support team members who scored 85 or higher, in F2.

    ABCDEF
    1NameDeptScoreHoursSupport 85+
    2AvaSales9442
    3BenSupport8138
    4CaraSales8845
    5DevOps9736
    6EvaSupport9141
    7FinnOps7344

    Hint: COUNTIFS takes pairs: range, condition, range, condition.

    Show answer

    =COUNTIFS(B2:B7,"Support",C2:C7,">=85") in F2. Eva (91) qualifies. Ben scored 81.

  4. Build: count Sales people working more than 40 hours

    Show answer

    =COUNTIFS(B2:B7,"Sales",D2:D7,">40"). Each condition comes as a range plus its criteria.

  5. What will B1 show?

    AB
    1Stapler
    2Sticker
    3Pen
    4Scissors

    B1 contains =COUNTIF(A1:A4,"S*")

    Show answer

    3. The * wildcard matches any characters, so S* matches anything starting with S.