1. Lighthouse

Level 1 · Import a CSV and clean it in three steps

The request

From Mei Morgan, Buyer

“The marketplace sent its June report for our Kitchen range, marketplace_june_kitchen.csv. I only need what actually sold, without the customer codes, and the prices came in as text so nothing adds up. I'll get the July file next month, so set it up once, please.”

Your goal

The Source step holds marketplace_june_kitchen.csv as imported. Add three steps: remove the customer_code column, keep only the rows whose status is not cancelled, and change unit_price to a decimal number.

  • Show exactly order_id order_date status product quantity unit_pricenot done yet
  • 27 rowsnot done yet

Your sheet

Excel
The sheet for this level
order_idorder_datestatuscustomer_codeproductquantityunit_price
197562025-06-01completedC00487Thatcher Cast Iron Bowl Set116.99
297632025-06-01completedC01459Linden Enamel Serving Platter119.99
397662025-06-02completedC01446Cove Cast Iron Dutch Oven1610.99
497662025-06-02completedC01446Willow Acacia Knife Block453.99
597682025-06-02completedC00185Oakley Enamel Dutch Oven1109.00
697842025-06-04completedC00173Hazel Porcelain Serving Platter1179.00
797842025-06-04completedC00173Tidewater Stainless Wine Glasses1169.00
897892025-06-04completedC00995Vale Enamel Bowl Set311.99
997902025-06-04completedC01089Alder Acacia Dutch Oven172.99
1098072025-06-06cancelledC01267Monroe Stoneware Utensil Set813.99
1198212025-06-07completedC01005Glen Stoneware Carafe260.99
1298432025-06-09completedC00636Cove Cast Iron Dutch Oven410.99
1398432025-06-09completedC00636Willow Acacia Knife Block853.99
1498452025-06-10completedC01099Thatcher Cast Iron Bowl Set216.99
1598522025-06-10completedC01010Hazel Stainless Dutch Oven1109.00
1698672025-06-12completedC00029Linden Enamel Serving Platter119.99
1798672025-06-12completedC00029Glen Stoneware Carafe160.99
1898672025-06-12completedC00029Thatcher Acacia Dutch Oven113.99
1998862025-06-14completedC00383Monroe Stoneware Utensil Set113.99
2098882025-06-14cancelledC00878Cove Cast Iron Dutch Oven410.99
2198882025-06-14cancelledC00878Willow Acacia Knife Block153.99
2298992025-06-15completedC00225Hazel Porcelain Serving Platter2179.00
2399092025-06-15cancelledC01359Thatcher Cast Iron Bowl Set116.99
2499322025-06-17completedC01487Vale Enamel Bowl Set211.99
25100232025-06-26completedC01427Cove Cast Iron Dutch Oven110.99
26100362025-06-26completedC00963Willow Acacia Knife Block153.99
27100402025-06-27cancelledC01278Thatcher Cast Iron Bowl Set216.99
28100472025-06-27completedC01109Cove Cast Iron Dutch Oven110.99
29100592025-06-28completedC01502Vale Enamel Bowl Set111.99
30100592025-06-28completedC01502Glen Stoneware Carafe260.99
31100722025-06-29completedC00003Hazel Porcelain Serving Platter2179.00
32100932025-06-30completedC00205Upland Acacia Serving Platter238.99

Loading the editor…

    ResultPress Check to compare the query result

    Mote checks your result

    Press Check. Each row of the result that matches becomes a firefly in your lantern.

    The lesson

    Every analyst has a file that arrives each month and needs the same clean-up each time. In Excel, Power Query is the tool for that: you connect to the file, and every change you make is recorded as a step. Next month, the steps replay on the new file by themselves.

    What you are working in

    This page is a practice editor for Power Query’s way of working, not Power Query itself. The table at the top is the Source step: the CSV as it was imported. You add steps in the box, one per line, and the editor shows the table after each step, like the Applied Steps pane in Excel. The step names and results match Power Query’s, so what you practise here is what you click at your desk.

    In real Excel the same import goes like this:

    1. Data → Get Data → From File → From Text/CSV (or Data → From Text/CSV), pick marketplace_june_kitchen.csv.
    2. A preview opens. Excel guesses the delimiter (comma, semicolon, tab) and the column types. Click Transform Data instead of Load, so the Power Query Editor opens.
    3. The Applied Steps pane on the right already shows Source, Promoted Headers (the first row became the column names) and usually Changed Type (Excel’s guess at the types).

    The original CSV is never touched. Power Query reads it and builds a cleaned copy; that is why you can always undo a step by deleting it from the list.

    Three steps on this file

    The source has 32 rows: order lines for Kitchen products sold on the marketplace in June 2025.

    Step What it does here In Excel
    Remove columns: customer_code drops the column the buyer doesn’t need right-click the header → Remove
    Filter rows: status <> cancelled keeps 27 rows; the 5 lines of 4 cancelled orders go arrow on the status header → untick cancelled
    Change type: unit_price to decimal "16.99" (text) becomes 16.99 (a number) click the ABC icon on the header → Decimal Number

    After the filter, status only holds completed. Order 9888 is a good one to watch: it had two lines and both disappear, because the filter tests each row on its own.

    Why the price needs a type

    unit_price came in as text. You can see it in the source: the marketplace writes 109.00, with the trailing zeros a number would drop. In Excel’s editor the column header shows ABC for text, 1.2 for a decimal and 123 for a whole number.

    Excel’s automatic Changed Type step is a guess based on the first rows, and exports with quoted or oddly formatted numbers often come in as text. Text looks like a number until you try to add it up: SUM skips it, and a multiplication in a custom column fails. Set the type yourself on every column you will calculate with. Here quantity is already a whole number, so only the price needs the step.

    The M behind the steps

    Each click writes one line of M, Power Query’s formula language. You never have to type it, but it is good to recognise it in View → Advanced Editor:

    #"Removed Columns" = Table.RemoveColumns(#"Promoted Headers", {"customer_code"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([status] <> "cancelled")),
    #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows", {{"unit_price", type number}})

    Each step names the step before it. That chain is the Applied Steps list.

    Load and refresh

    When the table looks right, Home → Close & Load puts it on a new sheet as an Excel Table. Next month, save the July file over the June one (same name, same folder) and press Data → Refresh All: the three steps run again on the new rows. If the file moves, edit the Source step (the gear icon next to it) and point it at the new path.

    Common mistakes

    • Writing the value in a different case. Power Query compares text exactly: status <> Cancelled keeps every row, because no row says Cancelled with a capital C.
    • Skipping Change type. The prices look like numbers but stay text, and every total built on them breaks.
    • Removing a column a later step needs. Steps run in order. If a filter on customer_code came after Remove columns: customer_code, it would fail with “There is no column”.
    • Clicking Load instead of Transform Data. The raw file lands on a sheet as-is. Open the query again with Data → Queries & Connections and double-click it.

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