The request

From George King, Sales Associate
Your goal
First flag first appearances: in E2:E55 put 1 when the order id in column A appears for the first time (counting from A2 down to this row), else 0; in F2:F55 the same for the product in column B. Then fill I3:I8: I3 the number of lines (COUNTA on B2:B55), I4 the number of orders (sum of E), I5 the number of different products (sum of F), I6 the lines with no coupon code in D2:D55 (COUNTBLANK), I7 the lines whose quantity (C2:C55) is greater than the number in I1 (COUNTIF, criterion built from I1), I8 the lines with a quantity of 1 or 2.
- Fill
E2:E55, F2:F55, I3:I8with the right valuesnot done yet - With formulas, not typed numbersnot done yet
- Use
COUNTACOUNTBLANKCOUNTIFnot done yet
Your sheet
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | order_id | product | quantity | coupon_code | new_order | new_product | Bulk means more than | 5 | ||
| 2 | 12295 | Birch Brass Floor Mirror | 3 | |||||||
| 3 | 12295 | Oakley Brass Framed Print | 1 | Order lines | ||||||
| 4 | 12300 | Cove Wool Lumbar Pillow | 2 | Orders | ||||||
| 5 | 12300 | Cove Cast Iron Dutch Oven | 4 | Different products | ||||||
| 6 | 12301 | Monroe Stoneware Utensil Set | 3 | Lines without a coupon | ||||||
| 7 | 12301 | Hazel Linen Throw Pillow | 3 | Bulk lines | ||||||
| 8 | 12301 | Oakley Jute Knit Throw | 6 | Lines of 1 or 2 units | ||||||
| 9 | 12301 | Avery Leather Bed Frame | 2 | |||||||
| 10 | 12303 | Vale Enamel Bowl Set | 2 | |||||||
| 11 | 12305 | Delancey Brass Vase | 2 | |||||||
| 12 | 12305 | Birch Brass Floor Mirror | 2 | |||||||
| 13 | 12313 | Delancey Black Metal Wall Sconce | 4 | |||||||
| 14 | 12313 | Hazel Porcelain Serving Platter | 1 | |||||||
| 15 | 12313 | Thatcher Marble Candle Holder Set | 9 | |||||||
| 16 | 12314 | Birch Brass Floor Mirror | 3 | |||||||
| 17 | 12314 | Fairhaven Stoneware Cutting Board | 1 | |||||||
| 18 | 12314 | Cove Cast Iron Dutch Oven | 2 | |||||||
| 19 | 12314 | Delancey Brass Vase | 1 | |||||||
| 20 | 12316 | Nantucket Brass Wall Mirror | 3 | |||||||
| 21 | 12316 | Hazel Linen Throw Pillow | 1 | |||||||
| 22 | 12317 | Glen Stoneware Carafe | 2 | HOLIDAY20 | ||||||
| 23 | 12317 | Delancey Brass Vase | 2 | HOLIDAY20 | ||||||
| 24 | 12322 | Delancey Black Metal Wall Sconce | 1 | |||||||
| 25 | 12322 | Monroe Glass Desk Lamp | 12 | |||||||
| 26 | 12322 | Vale Enamel Bowl Set | 4 | |||||||
| 27 | 12325 | Ridge Brass Bud Vase | 3 | |||||||
| 28 | 12325 | Oakley Jute Knit Throw | 8 | |||||||
| 29 | 12325 | Vale Enamel Bowl Set | 3 | |||||||
| 30 | 12328 | Maple Wool Throw Pillow | 4 | |||||||
| 31 | 12328 | Thatcher Oak Candle | 3 | |||||||
| 32 | 12328 | Hazel Stainless Dutch Oven | 2 | |||||||
| 33 | 12328 | Harbor Wool Knit Throw | 8 | |||||||
| 34 | 12332 | Ridge Ceramic Chandelier | 2 | HOLIDAY20 | ||||||
| 35 | 12332 | Cove Wool Lumbar Pillow | 1 | HOLIDAY20 | ||||||
| 36 | 12332 | Hazel Porcelain Serving Platter | 4 | HOLIDAY20 | ||||||
| 37 | 12341 | Thatcher Oak Candle | 4 | |||||||
| 38 | 12341 | Pacifica Black Metal Table Lamp | 1 | |||||||
| 39 | 12346 | Dune Ceramic Arc Lamp | 2 | |||||||
| 40 | 12346 | Spruce Wool Duvet Cover | 1 | |||||||
| 41 | 12346 | Elm Brass Floor Mirror | 1 | |||||||
| 42 | 12347 | Northfield Brass Bud Vase | 2 | |||||||
| 43 | 12347 | Cove Wool Lumbar Pillow | 2 | |||||||
| 44 | 12349 | Delancey Jute Area Rug | 2 | |||||||
| 45 | 12349 | Thatcher Oak Candle | 1 | |||||||
| 46 | 12349 | Glen Cotton Runner Rug | 2 | |||||||
| 47 | 12353 | Hazel Linen Throw Pillow | 4 | |||||||
| 48 | 12353 | Pacifica Black Metal Arc Lamp | 2 | |||||||
| 49 | 12360 | Fairhaven Brass Wall Sconce | 4 | |||||||
| 50 | 12360 | Alder Oak Coffee Table | 1 | |||||||
| 51 | 12360 | Elm Brass Floor Mirror | 4 | |||||||
| 52 | 12360 | Bramble Percale Quilt | 1 | |||||||
| 53 | 12361 | Vale Enamel Bowl Set | 4 | |||||||
| 54 | 12361 | Fern Oak Candle Holder Set | 3 | |||||||
| 55 | 12361 | Harbor Oak Floor Mirror | 6 | |||||||
| 56 | ||||||||||
| 57 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each right cell becomes a firefly in your lantern.
What George gets, and why
The lesson
Before you add anything up, find out what the data holds. How many rows are there? How many of them are real transactions? What’s missing? Excel has a small family of counting functions for this, and each one counts something different.
COUNT, COUNTA and COUNTBLANK
| Function | Counts | On this sheet |
|---|---|---|
=COUNT(C2:C55) |
cells holding a number | 54 quantities |
=COUNT(B2:B55) |
(the product names are text) | 0 |
=COUNTA(B2:B55) |
cells that are not empty: text, numbers, anything | 54 |
=COUNTBLANK(D2:D55) |
empty cells | 49 |
COUNT only counts numbers, so on a text column it returns 0. That is the classic slip when
someone asks “how many rows?” and gets nothing back. For “how many rows”, use COUNTA on a column
that is always filled, like the product name or an id.
COUNTA and COUNTBLANK are two halves of the same range. The coupon column has 5 filled cells
(HOLIDAY20 on two orders) and 49 empty ones, and 5 + 49 = 54. When the two halves don’t add up
to the row count, the range is the wrong size.
Lines are not orders
The sheet has one row per order line: order 12301 bought four products, so it takes four rows. George asked for both numbers, and they are different.
To count distinct orders in a sheet like this, flag the first time each order id appears. In E2:
E2 =IF(COUNTIF($A$2:A2,A2)=1,1,0)
The range $A$2:A2 has a locked start and a moving end. Filled down, row 5 reads $A$2:A5, row
9 reads $A$2:A9: it always runs from the top to the current row. So the COUNTIF asks “how many
times has this order id appeared so far?” It is 1 only on the order’s first line, so the flag is
1 there and 0 on every repeat. Add up the column, =SUM(E2:E55), and you get the number of
orders: 20. The same flag on column B counts 36 different products.
At your desk you may see two other ways. Microsoft 365 has =COUNTA(UNIQUE(A2:A55)), and older
workbooks use =SUMPRODUCT(1/COUNTIF(A2:A55,A2:A55)). Both make Excel work on a whole list of
values inside one cell. This practice sheet keeps one value per cell, so they don’t run here; the
flag column gives the same answer and works in every version. Its bonus: you can see which rows
counted, and filter on them.
Counting with a condition
COUNTIF counts the cells that pass one test. To count bulk lines, more than the 5 units in
I1:
I7 =COUNTIF(C2:C55,">"&I1)
The operator is in quotes and the cell is joined with &, so the criterion becomes >5. Six
lines pass: quantities of 6, 6, 8, 8, 9 and 12. The next levels take COUNTIF much further.
For “1 or 2 units”, one COUNTIF can’t test two values, but two of them added together can:
I8 =COUNTIF(C2:C55,1)+COUNTIF(C2:C55,2)
That’s 13 single-unit lines and 16 lines of two units: 29. A number criterion needs no quotes.
Because quantities are whole numbers, =COUNTIFS(C2:C55,">=1",C2:C55,"<=2") gives the same 29.
Sanity-check the counts
- The quantity bands should add up: 29 small lines, 19 lines of 3 to 5 units and 6 bulk lines make 54.
COUNT(C2:C55)should equalCOUNTA(C2:C55). If it’s lower, some quantities were imported as text, and every sum of that column is too low.- A distinct count can never be higher than the line count.
Common mistakes
- COUNT on text.
=COUNT(B2:B55)returns 0. UseCOUNTA. - Reporting lines as orders. Count distinct order ids, not rows.
- An unlocked start in the flag.
COUNTIF(A2:A2,A2)slides down as one cell, so every row counts 1 and the “orders” come out as 54. ">I1"in quotes. The criterion becomes the text “I1”; join the cell with&.- “1 or 2” in one criterion.
"1,2"matches nothing. Add twoCOUNTIFs.
Lantern lit!
Practised: countcountacountblankcountifdistinct count
- Solved
- No hints
- First run
