Cellwise

Unit 12 of 12

Dynamic arrays

One formula, whole tables of answers.

Functions in this unit: UNIQUE, COUNTA, SORT, FILTER, SUM, SEQUENCE

Key ideas

Formulas can spill

=UNIQUE(B2:B7)

One formula fills as many cells as it needs. Edit only the first cell.

FILTER keeps matching rows

=FILTER(A2:C7,C2:C7>100)

Give it the data and a TRUE/FALSE test. It returns every row that passes.

#SPILL! means blocked

#SPILL!

Something is in the way. Clear the cells where the results need to go.

Lesson 1: Spill basics

  1. What does it mean when a formula "spills"?

    • It fills neighboring cells with its results
    • It has an error
    • It deletes nearby data
    • It copies itself down
    Show answer

    It fills neighboring cells with its results. Modern Excel lets one formula return a whole list.

  2. List each region once, starting in F2.

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

    Hint: =UNIQUE(B2:B7)

    Show answer

    =UNIQUE(B2:B7) in F2. One formula, three answers. Add a new region and it updates.

  3. What will F1 show?

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

    F1 contains =COUNTA(UNIQUE(B2:B7))

    Show answer

    3. East, West and North.

  4. List the unit counts from highest to lowest, starting in F2.

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

    Hint: =SORT(C2:C7,1,-1). The -1 means descending.

    Show answer

    =SORT(C2:C7,1,-1) in F2. Your original data stays untouched.

  5. What does #SPILL! mean?

    • Cells where results need to go are not empty
    • The formula is misspelled
    • Division by zero
    • The lookup failed
    Show answer

    Cells where results need to go are not empty. Clear the blocking cells and the results appear.

Lesson 2: FILTER

  1. List every product sold in the West, starting in F2.

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

    Hint: =FILTER(A2:A7,B2:B7="West")

    Show answer

    =FILTER(A2:A7,B2:B7="West") in F2. Like an AutoFilter that never needs refreshing.

  2. Return the Product, Region and Units of every row with more than 100 units, starting in F2.

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

    Hint: =FILTER(A2:C7,C2:C7>100)

    Show answer

    =FILTER(A2:C7,C2:C7>100) in F2. FILTER can return whole rows, not just one column.

  3. Build: products under $5, or "None" if there are none

    Show answer

    =FILTER(A2:A7,D2:D7<5,"None"). The third argument is what to show when nothing matches.

  4. What will F1 show?

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

    F1 contains =SUM((B2:B7="East")*C2:C7)

    Show answer

    165. The test makes 1s and 0s, so only East units survive: 120 + 45.

  5. When does FILTER use its third argument?

    • When no rows match
    • When the data has blanks
    • Always
    • When there is an error in the data
    Show answer

    When no rows match. Without it, an empty result shows #CALC!.

Lesson 3: Array math

  1. Total the East units without using SUMIF. Put it in F2.

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

    Hint: =SUM((B2:B7="East")*C2:C7)

    Show answer

    =SUM((B2:B7="East")*C2:C7) in F2. TRUE times a number counts it, FALSE times a number zeroes it.

  2. Fill the month numbers 1 to 12 with one formula in A2.

    A
    1Month
    2

    Hint: =SEQUENCE(12)

    Show answer

    =SEQUENCE(12) in A2. SEQUENCE builds numbered lists instantly.

  3. Calculate revenue for every row at once with a single formula in E2.

    ABCDE
    1ProductRegionUnitsPriceRevenue
    2NotebookEast1203.5
    3PenWest3401.25
    4StaplerEast4512
    5BinderNorth806.75
    6MarkerWest2102.4
    7FolderNorth1501.9

    Hint: Multiply the two whole columns: =C2:C7*D2:D7

    Show answer

    =C2:C7*D2:D7 in E2. No fill down needed. The formula spills.

  4. Why are spilling formulas safer than filling down?

    • There is only one formula to check and it resizes itself
    • They calculate faster
    • They cannot have errors
    • They use less color
    Show answer

    There is only one formula to check and it resizes itself. Filled formulas can drift when someone edits one row.

  5. List each region once, sorted A to Z, starting in F2.

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

    Hint: =SORT(UNIQUE(B2:B7))

    Show answer

    =SORT(UNIQUE(B2:B7)) in F2. Nest them like any other functions.