1. Lighthouse

Level 4 · A price histogram with COUNTIFS

The request

From Mei Morgan, Buyer

“I'm planning next year's Kitchen, Textiles and Decor range and I want to see where our prices bunch up and where the gaps are. Count the 60 products into $50 price bands and chart it, please.”

Your goal

Each price band has a lower bound in G2:G7 and an upper bound in H2:H7. In I2:I7, count the products whose unit_price (D2:D61) is at least the lower bound and below the upper bound, with COUNTIFS; write it once in I2 and fill down. In I8, add up I2:I7 as a check.

  • Fill I2:I8 with the right valuesnot done yet
  • With formulas, not typed numbersnot done yet
  • Use COUNTIFSnot done yet

Your sheet

Excel
The sheet for this level
ABCDEFGHIJ
1product_idnamecategoryunit_priceprice bandfromtoproducts
2141Thatcher Acacia Dutch OvenKitchen13.99$0–50050
3142Upland Acacia Serving PlatterKitchen38.99$50–10050100
4143Pine Cast Iron CarafeKitchen289.00$100–150100150
5144Hazel Porcelain Cutting BoardKitchen129.00$150–200150200
6145Cove Cast Iron Dutch OvenKitchen10.99$200–250200250
7146Thatcher Cast Iron Bowl SetKitchen16.99$250–300250300
8147Cedar Cast Iron Tumbler SetKitchen79.99Total
9148Spruce Enamel Utensil SetKitchen239.00
10149Hazel Stainless Dutch OvenKitchen109.00
11150Linden Enamel Serving PlatterKitchen19.99
12151Glen Stoneware CarafeKitchen60.99
13152Monroe Stoneware Utensil SetKitchen13.99
14153Alder Acacia Dutch OvenKitchen72.99
15154Vale Enamel Bowl SetKitchen11.99
16155Tidewater Stainless Wine GlassesKitchen169.00
17156Willow Acacia Knife BlockKitchen53.99
18157Oakley Enamel Dutch OvenKitchen109.00
19158Hazel Porcelain Serving PlatterKitchen179.00
20159Driftwood Porcelain CarafeKitchen179.00
21160Fairhaven Stoneware Cutting BoardKitchen70.99
22161Cove Jute Duvet CoverTextiles219.00
23162Oakley Jute Knit ThrowTextiles23.99
24163Pine Cotton Area RugTextiles139.00
25164Cove Wool Lumbar PillowTextiles52.99
26165Weston Cashmere-Blend QuiltTextiles25.99
27166Harbor Wool Knit ThrowTextiles28.99
28167Elm Cashmere-Blend Area RugTextiles86.99
29168Upland Percale Lumbar PillowTextiles159.00
30169Spruce Wool Duvet CoverTextiles66.99
31170Rowan Cashmere-Blend Throw BlanketTextiles17.99
32171Driftwood Percale Area RugTextiles27.99
33172Maple Wool Throw PillowTextiles18.99
34173Bramble Percale QuiltTextiles139.00
35174Vale Cashmere-Blend Knit ThrowTextiles18.99
36175Glen Cotton Runner RugTextiles84.99
37176Fairhaven Cotton Throw PillowTextiles78.99
38177Delancey Cashmere-Blend Duvet CoverTextiles169.00
39178Sutton Wool Knit ThrowTextiles70.99
40179Delancey Jute Area RugTextiles30.99
41180Hazel Linen Throw PillowTextiles20.99
42181Cedar Marble Bud VaseDecor179.00
43182Nantucket Brass Wall MirrorDecor17.99
44183Glen Glass Canvas PrintDecor189.00
45184Thatcher Oak CandleDecor17.99
46185Ridge Brass Bud VaseDecor12.99
47186Birch Brass Floor MirrorDecor20.99
48187Ashford Oak Canvas PrintDecor149.00
49188Fern Oak Candle Holder SetDecor179.00
50189Northfield Brass Bud VaseDecor76.99
51190Elm Brass Floor MirrorDecor43.99
52191Hazel Ceramic Canvas PrintDecor45.99
53192Thatcher Marble Candle Holder SetDecor15.99
54193Delancey Brass VaseDecor19.99
55194Chester Brass Wall MirrorDecor159.00
56195Fairhaven Soy Wax Framed PrintDecor103.99
57196Pine Glass Candle Holder SetDecor25.99
58197Ridge Soy Wax VaseDecor109.00
59198Harbor Oak Floor MirrorDecor44.99
60199Oakley Brass Framed PrintDecor104.99
61200Cedar Ceramic CandleDecor179.00
62
63

Loading the editor…

    ResultPress Check to compare I2:I8

    Mote checks your result

    Press Check. Each right cell becomes a firefly in your lantern.

    The lesson

    An average hides the shape of the data. The 60 products on this sheet average $84.09. That could mean most of them cost about $84, or that many cost $20 and a few cost $250. A histogram shows which: it splits the range of values into equal bins and draws one column per bin, as tall as the number of values that fall in it.

    Bins: lower bound in, upper bound out

    Each band on the sheet has a lower bound (G) and an upper bound (H), both $50 apart. A price belongs to a band when it is at least the lower bound and below the upper bound. That rule puts every price in exactly one bin, including a price that sits exactly on a boundary.

    Band Condition
    $0–50 price >= 0 and price < 50
    $50–100 price >= 50 and price < 100
    … …
    $250–300 price >= 250 and price < 300

    COUNTIFS with two conditions on one column

    COUNTIFS takes pairs of (range, criteria) and counts the rows that pass all of them. Both pairs can test the same column:

    I2   =COUNTIFS($D$2:$D$61,">="&G2,$D$2:$D$61,"<"&H2)

    The & glues the operator to the number in the cell, building ">=0" and "<50". Keeping the bounds in cells means you can try $25 bands later by changing two columns, not six formulas. Then the check:

    I8   =SUM(I2:I7)

    I8 must be 60, one per product. Fewer means a price fell outside every bin (raise the top bound); more means a price counted twice (an <= crept in).

    Making it in Excel

    Select F1:F7, hold Ctrl (Cmd on a Mac) and select I1:I7, then Insert → Charts → Column. In Chart Design → Add Chart Element, add axis titles (“Price band”, “Products”). A histogram’s columns traditionally touch: right-click a column → Format Data Series → Gap Width 0%.

    Excel 2016 and later can also build it in one step from the raw prices: select D1:D61, then Insert → Charts → Statistic → Histogram, and set the bin width to 50 under Format Axis. Its bins work the other way around, upper bound in, lower bound out, so a price of exactly 50.00 would land in the first bin there. Google Sheets has a Histogram chart type too. The COUNTIFS table is worth knowing because you control the bins and can reuse the counts in other formulas.

    What the chart shows

    The shape is lopsided. 26 of the 60 products, 43%, cost under $50, and the columns fall to 12 between $50 and $100, then 9 and 10 in the next two bands. Above $200 there are only 3 products: 2 between $200 and $250 and 1 between $250 and $300. This range is a cheap-items business with a thin premium tail. The tail also explains the average: half the products cost $68.99 or less (the median), but the few expensive ones pull the average up to $84.09. If Mei wants a “better” tier, the gap above $200 is where it would go.

    Common mistakes

    • Overlapping bins (>= and <= on both ends): boundary values count twice.
    • Bins of different widths. A $0–50 bin next to a $50–300 bin makes the second look busier only because it is wider. Keep widths equal.
    • Forgetting the &. ">=G2" is the text “greater than or equal to G2”, which matches nothing, and the bin count is 0.
    • Not checking the total. I8 is a one-second test that catches all of the above.

    Pick what may run on this site. You can change this any time from "Cookie settings" at the bottom of every page.