For teachers / Answer key
Answer key: Modern Excel
For teachers. This page is kept out of search engines and linked only from the teachers page. Students can see the same answers in a lesson with Show answer. Any formula that gives the right values counts.
1. Spilling arrays: UNIQUE and SORT (Intermediate, 5 min)
Which plants have people ordered? In
D2, type=UNIQUE(B2:B13)and press Enter. You only type in one cell; the rest of the list spills down by itself.D2=UNIQUE(B2:B13)
Shows D2: Monstera, D3: Snake plant, D4: Pothos, D5: Fiddle-leaf fig, D6: Peace lily
Now the customers. In
E2, sort the names A to Z with=SORT(A2:A13).E2=SORT(A2:A13)
Shows E2: Arjun, E3: Arjun, E4: Bao, E5: Elena, E6: Elena, E7: Kofi, and 6 more
Edit
E2so it removes the duplicates first, then sorts:=SORT(UNIQUE(A2:A13)). Watch the spill range shrink to fit.E2=SORT(UNIQUE(A2:A13))
Shows E2: Arjun, E3: Bao, E4: Elena, E5: Kofi, E6: Mei, E7: Rosa
How many different plants are there? In
H2, count the list in column D with=COUNTA(D2#). The#after D2 means the whole spill range that starts in D2.H2=COUNTA(D2#)
Shows H2: 5
Elena just changed her order. Replace Snake plant in
B13withCactus, then watch the list in column D and the count inH2.B13Cactus
Shows B13: Cactus
2. FILTER: rows that match (Intermediate, 6 min)
Your friend needs room for a home office. In
F6, list every flat with at least 2 bedrooms:=FILTER(A2:D13, C2:C13>=2)F6=FILTER(A2:D13, C2:C13>=2)
Shows F6: Canal View 4A, G6: Riverside, H6: 2, I6: $1,650, F7: Elm Court 12, G7: Harbourside, and 26 more
Typing the condition into the formula means editing it every time it changes. Edit
F6to show the flats in the area named inG1:=FILTER(A2:D13, B2:B13=G1)F6=FILTER(A2:D13, B2:B13=G1)
Shows F6: Tannery Loft, G6: Old Town, H6: 1, I6: $1,200, F7: Bell Lane Studio, G7: Old Town, and 14 more
Your friend would also consider the area in
G2. To keep rows that pass either test, add the tests together with+:=FILTER(A2:D13, (B2:B13=G1)+(B2:B13=G2))F6=FILTER(A2:D13, (B2:B13=G1)+(B2:B13=G2))
Shows F6: Canal View 4A, G6: Riverside, H6: 2, I6: $1,650, F7: Tannery Loft, G7: Old Town, and 30 more
Back to one area, but now there is a budget. Rows must be in the
G1area and cost no more thanG3. Multiply the tests with:=FILTER(A2:D13, (B2:B13=G1)(D2:D13<=G3))F6=FILTER(A2:D13, (B2:B13=G1)*(D2:D13<=G3))
Shows F6: Tannery Loft, G6: Old Town, H6: 1, I6: $1,200, F7: Bell Lane Studio, G7: Old Town, and 6 more
What if nothing fits? Lower the budget in
G3to900:F6now shows #CALC! because no rows match. Fix it by adding a third argument,"No matches", to the FILTER inF6.G3900F6=FILTER(A2:D13, (B2:B13=G1)*(D2:D13<=G3), "No matches")
Shows G3: $900, F6: No matches
3. SORTBY, SEQUENCE and LET (Advanced, 5 min)
Rank the teams by points, highest first. In
F2, use=SORTBY(A2:A9, C2:C9, -1): sort the names in column A by the points in column C. The-1means descending.F2=SORTBY(A2:A9, C2:C9, -1)
Shows F2: Know-It-Owls, F3: Quizzly Bears, F4: The Brainstormers, F5: Fact Hunters, F6: Question Marks, F7: Smarty Pints, and 2 more
Number the places. In
E2,=SEQUENCE(8)spills the numbers 1 to 8 down the column, one for each team.E2=SEQUENCE(8)
Shows E2: 1, E3: 2, E4: 3, E5: 4, E6: 5, E7: 6, and 2 more
Raw points favour teams that have played more. In
G2, rank the teams by points per game instead. SORTBY can sort by a calculation:=SORTBY(A2:A9, C2:C9/B2:B9, -1)G2=SORTBY(A2:A9, C2:C9/B2:B9, -1)
Shows G2: Quizzly Bears, G3: Know-It-Owls, G4: Smarty Pints, G5: Fact Hunters, G6: The Brainstormers, G7: Question Marks, and 2 more
How spread out is the league? In
B11, find the best points per game minus the worst. Instead of typingC2:C9/B2:B9twice, name it once with LET:=LET(ppg, C2:C9/B2:B9, MAX(ppg)-MIN(ppg))B11=LET(ppg, C2:C9/B2:B9, MAX(ppg)-MIN(ppg))
Shows B11: 1.50
4. Reshape a list: TAKE, DROP and CHOOSECOLS (Intermediate, 5 min)
Who are the top three? In
E2, sort the table by sales, highest first, and keep only the first three rows:=TAKE(SORT(A2:C11, 3, -1), 3)E2=TAKE(SORT(A2:C11, 3, -1), 3)
Shows E2: Hana, F2: South, G2: $6,100, E3: Chloe, F3: North, G3: $5,600, and 3 more
Now everyone who is not in the top three. In
E7, drop the first three rows of the same ranking:=DROP(SORT(A2:C11, 3, -1), 3)E7=DROP(SORT(A2:C11, 3, -1), 3)
Shows E7: Jo, F7: North, G7: $4,400, E8: Ana, F8: North, G8: $4,200, and 15 more
The region is not needed in the summary. In
I2, keep only the first and third columns of the top three:=CHOOSECOLS(TAKE(SORT(A2:C11, 3, -1), 3), 1, 3)I2=CHOOSECOLS(TAKE(SORT(A2:C11, 3, -1), 3), 1, 3)
Shows I2: Hana, J2: $6,100, I3: Chloe, J3: $5,600, I4: Eve, J4: $4,900
5. Combine lists: VSTACK and HSTACK (Intermediate, 5 min)
Put both months in one list. In
G2, stack February under January:=VSTACK(A2:B5, D2:E5)G2=VSTACK(A2:B5, D2:E5)
Shows G2: Rosa, H2: $120, G3: Kofi, H3: $80, G4: Mei, H4: $200, and 10 more
Who ordered at all, in either month? In
J2, stack the two customer columns and remove the repeats:=UNIQUE(VSTACK(A2:A5, D2:D5))J2=UNIQUE(VSTACK(A2:A5, D2:D5))
Shows J2: Rosa, J3: Kofi, J4: Mei, J5: Arjun, J6: Elena
Finally, a summary with each customer and what they spent in total. In
L2, put the customer list fromJ2beside a SUMIF of the stacked orders:=HSTACK(J2#, SUMIF(G2:G9, J2#, H2:H9))L2=HSTACK(J2#, SUMIF(G2:G9, J2#, H2:H9))
Shows L2: Rosa, M2: $180, L3: Kofi, M3: $230, L4: Mei, M4: $240, and 4 more
6. Your own calculations: LAMBDA, BYROW and MAP (Advanced, 7 min)
In
H2, give each coffee its total for the year, one per row:=BYROW(B2:E7, LAMBDA(row, SUM(row)))H2=BYROW(B2:E7, LAMBDA(row, SUM(row)))
Shows H2: 1350, H3: 580, H4: 860, H5: 400, H6: 1180, H7: 395
Which coffees sold at least 100 in every quarter?
ANDturns a whole row of tests into one answer, which is exactly what BYROW needs. InI2:=BYROW(B2:E7, LAMBDA(row, AND(row>=100)))I2=BYROW(B2:E7, LAMBDA(row, AND(row>=100)))
Shows I2: TRUE, I3: TRUE, I4: TRUE, I5: FALSE, I6: TRUE, I7: FALSE
Now the other direction: a total for each quarter. In
B8:=BYCOL(B2:E7, LAMBDA(col, SUM(col)))B8=BYCOL(B2:E7, LAMBDA(col, SUM(col)))
Shows B8: 1095, C8: 1100, D8: 1215, E8: 1355
Reorder when stock is below a third of last quarter's sales. MAP can walk two ranges in step, giving the LAMBDA one value from each. In
J2:=MAP(F2:F7, E2:E7, LAMBDA(stock, sold, IF(stock<sold/3, "Reorder", "OK")))J2=MAP(F2:F7, E2:E7, LAMBDA(stock, sold, IF(stock<sold/3, "Reorder", "OK")))
Shows J2: Reorder, J3: OK, J4: Reorder, J5: OK, J6: Reorder, J7: OK
7. Running results: SCAN and REDUCE (Advanced, 6 min)
In
C2, build a running balance that starts from 0:=SCAN(0, B2:B13, LAMBDA(balance, cash, balance+cash))C2=SCAN(0, B2:B13, LAMBDA(balance, cash, balance+cash))
Shows C2: $1,200, C3: $800, C4: $150, C5: $1,050, C6: $750, C7: $550, and 6 more
The business did not start the year at zero. Edit
C2so the balance starts from the opening balance inF1instead of 0.C2=SCAN(F1, B2:B13, LAMBDA(balance, cash, balance+cash))
Shows C2: $3,200, C3: $2,800, C4: $2,150, C5: $3,050, C6: $2,750, C7: $2,550, and 6 more
How many months lost money? REDUCE carries a count down the list and keeps only the final number. In
F3:=REDUCE(0, B2:B13, LAMBDA(count, cash, IF(cash<0, count+1, count)))F3=REDUCE(0, B2:B13, LAMBDA(count, cash, IF(cash<0, count+1, count)))
Shows F3: 6
What was the longest run of losing months in a row? SCAN can count a streak that resets to 0 after a good month, and MAX picks the longest. In
F4:=MAX(SCAN(0, B2:B13, LAMBDA(run, cash, IF(cash<0, run+1, 0))))F4=MAX(SCAN(0, B2:B13, LAMBDA(run, cash, IF(cash<0, run+1, 0))))
Shows F4: 3