1. Lighthouse

Level 7 · Boss: a day's sales, from lines to a pivot to the headline

The request

From Priya Shah, Head of Data

“Robert asked what sold on Monday May 12. Here are the day's 39 order lines, all statuses mixed. I want completed revenue per category in a PivotTable, and above it the headline: which category won, how much, what share, and who came second.”

Your goal

Step 1 of 3. In G1 type line_total, and in G2:G40 compute each line's revenue: quantity times unit_price, minus the discount (discount_pct is a percentage).

  • Fill G2:G40 with the right valuesnot done yet
  • With formulas, not typed numbersnot done yet

Step 1 · your sheet

Excel
The sheet for this level
ABCDEFGHIJKLMN
1order_idcategorystatusquantityunit_pricediscount_pctTop category
29515Outdoorcompleted11099.000Its revenue
39515Outdoorcompleted2249.000Share of completed revenue
49516Decorcompleted244.990Runner-up
59516Decorcompleted415.990
69517Outdoorcompleted450.990
79517Textilescompleted128.990
89518Outdoorcompleted193.990
99519Outdoorcompleted272.990
109520Decorcompleted119.990
119521Textilescompleted1169.000
129521Textilescompleted120.990
139521Outdoorcompleted153.990
149522Decorcompleted125.9910
159522Textilescompleted128.9910
169522Outdoorcompleted293.9910
179523Textilescompleted252.990
189523Outdoorcompleted3379.000
199524Textilescompleted152.990
209524Decorcompleted119.990
219524Outdoorcompleted153.990
229524Decorcompleted220.990
239525Outdoorcompleted4379.000
249526Kitchencompleted811.990
259526Decorcompleted219.990
269527Decorrefunded1104.990
279528Outdoorcompleted150.990
289528Outdoorcompleted1289.000
299528Textilescompleted117.990
309529Lightingcancelled2109.000
319529Kitchencancelled210.990
329529Textilescancelled130.990
339529Decorcancelled220.990
349529Lightingcancelled229.990
359529Kitchencancelled211.990
369530Textilescompleted170.990
379530Decorcompleted3109.000
389530Kitchencompleted153.990
399530Lightingcompleted451.990
409530Outdoorcompleted253.990
41
42
43
44
45

Loading the editor…

    ResultPress Check to compare G2:G40

    Mote checks your result

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

    Step 2 · your sheet

    Excel
    The sheet for this level
    ABCDEFGHIJKLMN
    1order_idcategorystatusquantityunit_pricediscount_pctline_totalTop category
    29515Outdoorcompleted11099.0001,099.00Its revenue
    39515Outdoorcompleted2249.000498.00Share of completed revenue
    49516Decorcompleted244.99089.98Runner-up
    59516Decorcompleted415.99063.96
    69517Outdoorcompleted450.990203.96
    79517Textilescompleted128.99028.99
    89518Outdoorcompleted193.99093.99
    99519Outdoorcompleted272.990145.98
    109520Decorcompleted119.99019.99
    119521Textilescompleted1169.000169.00
    129521Textilescompleted120.99020.99
    139521Outdoorcompleted153.99053.99
    149522Decorcompleted125.991023.39
    159522Textilescompleted128.991026.09
    169522Outdoorcompleted293.9910169.18
    179523Textilescompleted252.990105.98
    189523Outdoorcompleted3379.0001,137.00
    199524Textilescompleted152.99052.99
    209524Decorcompleted119.99019.99
    219524Outdoorcompleted153.99053.99
    229524Decorcompleted220.99041.98
    239525Outdoorcompleted4379.0001,516.00
    249526Kitchencompleted811.99095.92
    259526Decorcompleted219.99039.98
    269527Decorrefunded1104.990104.99
    279528Outdoorcompleted150.99050.99
    289528Outdoorcompleted1289.000289.00
    299528Textilescompleted117.99017.99
    309529Lightingcancelled2109.000218.00
    319529Kitchencancelled210.99021.98
    329529Textilescancelled130.99030.99
    339529Decorcancelled220.99041.98
    349529Lightingcancelled229.99059.98
    359529Kitchencancelled211.99023.98
    369530Textilescompleted170.99070.99
    379530Decorcompleted3109.000327.00
    389530Kitchencompleted153.99053.99
    399530Lightingcompleted451.990207.96
    409530Outdoorcompleted253.990107.98
    41
    42
    43
    44
    45

    Loading the editor…

      ResultPress Check to compare I1:J9

      Mote checks your result

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

      Step 3 · your sheet

      Excel
      The sheet for this level
      ABCDEFGHIJKLMNO
      1order_idcategorystatusquantityunit_pricediscount_pctline_totalstatuscompletedTop category
      29515Outdoorcompleted11099.0001,099.00Its revenue
      39515Outdoorcompleted2249.000498.00categorySum of line_totalShare of completed revenue
      49516Decorcompleted244.99089.98Decor626.27Runner-up
      59516Decorcompleted415.99063.96Kitchen149.91
      69517Outdoorcompleted450.990203.96Lighting207.96
      79517Textilescompleted128.99028.99Outdoor5,419.06
      89518Outdoorcompleted193.99093.99Textiles493.02
      99519Outdoorcompleted272.990145.98Grand Total6,896.22
      109520Decorcompleted119.99019.99
      119521Textilescompleted1169.000169.00
      129521Textilescompleted120.99020.99
      139521Outdoorcompleted153.99053.99
      149522Decorcompleted125.991023.39
      159522Textilescompleted128.991026.09
      169522Outdoorcompleted293.9910169.18
      179523Textilescompleted252.990105.98
      189523Outdoorcompleted3379.0001,137.00
      199524Textilescompleted152.99052.99
      209524Decorcompleted119.99019.99
      219524Outdoorcompleted153.99053.99
      229524Decorcompleted220.99041.98
      239525Outdoorcompleted4379.0001,516.00
      249526Kitchencompleted811.99095.92
      259526Decorcompleted219.99039.98
      269527Decorrefunded1104.990104.99
      279528Outdoorcompleted150.99050.99
      289528Outdoorcompleted1289.000289.00
      299528Textilescompleted117.99017.99
      309529Lightingcancelled2109.000218.00
      319529Kitchencancelled210.99021.98
      329529Textilescancelled130.99030.99
      339529Decorcancelled220.99041.98
      349529Lightingcancelled229.99059.98
      359529Kitchencancelled211.99023.98
      369530Textilescompleted170.99070.99
      379530Decorcompleted3109.000327.00
      389530Kitchencompleted153.99053.99
      399530Lightingcompleted451.990207.96
      409530Outdoorcompleted253.990107.98
      41
      42
      43
      44
      45

      Loading the editor…

        ResultPress Check to compare M1:M4

        Mote checks your result

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

        The lesson

        One day, three layers

        A useful sales note has three layers: the lines (what happened), a summary (where the money went) and a headline (what to say first). This boss builds all three on Monday, May 12, 2025: 39 order lines in A1:F40, completed, cancelled and refunded mixed together.

        Step 1: a field to add up

        The export has quantity, price and discount but no revenue. A PivotTable can only summarise a field that exists, so first add one:

        G1   line_total
        G2   =D2*E2*(1-F2/100)

        Filled down to G40. With a header and no gap, column G becomes part of the pivot’s source, just as it would in Excel if the data were a Table (Ctrl+T). In Excel you could also add a calculated field instead, but a helper column is visible and easy to check.

        Step 2: completed revenue by category

        Status belongs in Filter: the question is about completed sales only, not a split by status.

        Filter    status = completed
        Rows      category
        Values    Sum of line_total
        status        completed
        
        category      Sum of line_total
        Decor               626.27
        Kitchen             149.91
        Lighting            207.96
        Outdoor           5,419.06
        Textiles            493.02
        Grand Total       6,896.22

        Without the filter the Grand Total would be 7,398.12: the six cancelled lines (396.91) and one refunded line (104.99) would count as sales.

        Step 3: the headline, read from the pivot

        The pivot’s values are ordinary cells, so formulas can read them. Keep the rows in A→Z order and let the formulas find the winner, so the headline doesn’t depend on how the pivot is sorted:

        M2   =LARGE(J4:J8,1)                          biggest category revenue
        M1   =INDEX(I4:I8,MATCH(M2,J4:J8,0))          the label next to it
        M3   =M2/J9                                   share of the Grand Total
        M4   =INDEX(I4:I8,MATCH(LARGE(J4:J8,2),J4:J8,0))

        LARGE(range, k) returns the k-th largest value, so k = 2 is the runner-up. MATCH(…, 0) finds its position and INDEX returns the category in the same position, the same pair you met in chapter 2.

        In Excel, clicking a pivot cell while typing a formula inserts a GETPIVOTDATA(…) call instead of J4. It reads a value by field name, so it survives a re-sorted pivot; plain references like J4:J8 are easier to read and are what this sheet supports. You can switch the habit off under PivotTable Analyze → Options → Generate GetPivotData.

        Thinking like an analyst

        Outdoor at 78.6% of a Monday in May is the start of patio season, not a one-off: the next ticket would compare the same weekday across April and June. And the 501.90 of cancelled or refunded lines is worth one sentence in the note, because it is the difference between the till and the sales report.

        Common mistakes

        • Putting status in Rows instead of Filter: the table splits into three lines per category.
        • A helper column without a header, which the pivot can’t see.
        • Typing 5,419.06 into M2: the headline goes stale the moment the pivot changes.
        • MATCH without the 0: an approximate match on unsorted numbers returns the wrong category.

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