1. Lighthouse

Level 2 · Split a payment code, combine two columns

The request

From Amanda Perez, Accountant

“I'm reconciling the marketplace's February settlement report, settlement_feb_2025.csv. Their transaction codes look like TX-2025-008514, and the last part is our order number, which is what I match on. Their chargeback list names items as product-customer, like 153-C01247, so I need that key too.”

Your goal

Split transaction_id at each "-", keep only the number part as a whole-number column named order_id (drop the other two parts), then add a column product_customer that joins product_id, a hyphen and customer_code (for example 153-C01247).

  • Show exactly order_id order_date customer_code product_id quantity amount product_customernot done yet
  • 53 rowsnot done yet

Your sheet

Excel
The sheet for this level
transaction_idorder_datecustomer_codeproduct_idquantityamount
1TX-2025-0085142025-02-01C01247153165.69
2TX-2025-0085222025-02-01C00461185221.6
3TX-2025-0085222025-02-01C00461152225.18
4TX-2025-0085312025-02-02C00844164152.99
5TX-2025-0085442025-02-04C006971734556
6TX-2025-0085442025-02-04C00697190287.98
7TX-2025-0085502025-02-04C004961631139
8TX-2025-0085542025-02-04C00916122259.98
9TX-2025-0085542025-02-04C009161666161.94
10TX-2025-0085542025-02-04C00916186241.98
11TX-2025-0086072025-02-11C01153169166.99
12TX-2025-0086142025-02-12C00453184117.99
13TX-2025-0086172025-02-12C001841193777
14TX-2025-0086172025-02-12C00184142273.98
15TX-2025-0086172025-02-12C00184193239.98
16TX-2025-0086222025-02-13C01089165125.99
17TX-2025-0086222025-02-13C01089121131.99
18TX-2025-0086222025-02-13C01089150118.99
19TX-2025-0086222025-02-13C01089166126.99
20TX-2025-0086222025-02-13C01089184471.96
21TX-2025-0086242025-02-13C004711943447
22TX-2025-0086242025-02-13C00471150475.96
23TX-2025-0086272025-02-13C010871812358
24TX-2025-0086272025-02-13C01087190143.99
25TX-2025-0086282025-02-13C002341532145.98
26TX-2025-0086372025-02-14C010302032107.98
27TX-2025-0086372025-02-14C01030141113.99
28TX-2025-0086372025-02-14C01030191142.99
29TX-2025-0086442025-02-15C01269184235.98
30TX-2025-0086442025-02-15C012692152187.98
31TX-2025-0086442025-02-15C012691469143.91
32TX-2025-0086442025-02-15C012691993296.97
33TX-2025-0086662025-02-18C007061731139
34TX-2025-0086732025-02-19C01277185221.6
35TX-2025-0086732025-02-19C012771062412.2
36TX-2025-0086732025-02-19C01277141112.59
37TX-2025-0086732025-02-19C01277191138.69
38TX-2025-0086962025-02-22C00520154111.99
39TX-2025-0087012025-02-22C008131942298
40TX-2025-0087162025-02-24C004671271179
41TX-2025-0087162025-02-24C00467193479.96
42TX-2025-0087162025-02-24C0046721441036
43TX-2025-0087162025-02-24C0046711221038
44TX-2025-0087242025-02-25C01284193117.99
45TX-2025-0087242025-02-25C01284133288.18
46TX-2025-0087242025-02-25C012841731125.1
47TX-2025-0087372025-02-27C003511771169
48TX-2025-0087372025-02-27C003511061229
49TX-2025-0087372025-02-27C00351150118.99
50TX-2025-0087432025-02-28C009891591179
51TX-2025-0087432025-02-28C009891392358
52TX-2025-0087472025-02-28C000091871149
53TX-2025-0087472025-02-28C00009164152.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

    Exports from other systems rarely use your ids as they are. The marketplace wraps our order number in a transaction code, TX-2025-008514, and Amanda needs the plain number back to match the report against our orders. That is a Split Column job. Then she needs the opposite: two columns combined into one key.

    Split a column by a delimiter

    Split column: transaction_id by "-"

    Power Query cuts the text at every hyphen and puts each piece in its own column, named after the original with .1, .2, .3:

    transaction_id → transaction_id.1 transaction_id.2 transaction_id.3
    TX-2025-008514 TX 2025 008514

    The three new columns take the place of transaction_id, which is gone. Keep the piece you need and remove the others:

    Remove columns: transaction_id.1, transaction_id.2
    Rename column: transaction_id.3 to order_id

    In Excel: select the column, Home → Split Column → By Delimiter, pick --Custom-- and type -, choose Each occurrence of the delimiter. Rename by double-clicking the header.

    The number part is still text

    008514 is text: the leading zeros give it away, because a number has none. Our order ids are numbers (8514), so text "008514" would never match them in a lookup or a merge. One more step fixes it:

    Change type: order_id to whole number

    Real Excel usually adds this one by itself: right after a split, Power Query inserts a Changed Type step that guesses the new columns’ types. Always look at what it guessed. A code like 00123 that must keep its zeros (a ZIP code, a SKU) has to stay text.

    Combine two columns into a key

    The chargeback list identifies an item as 153-C01247: the product id, a hyphen, the customer code. Build the same key with a custom column:

    Add column: product_customer = Text.From([product_id]) & "-" & [customer_code]

    & joins text. product_id is a number, and M, unlike an Excel cell formula, refuses to join a number to text: [product_id] & "-" is an error on every row. Text.From converts the number to text first. On the first row this gives 153-C01247.

    In Excel the point-and-click version is Add Column → Merge Columns: select product_id, then customer_code (the click order is the order in the result), pick a custom separator -, and name the new column. Use the Transform tab’s Merge Columns instead if you want the two originals replaced rather than kept.

    The M behind the steps

    Table.SplitColumn(Source, "transaction_id",
        Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv),
        {"transaction_id.1", "transaction_id.2", "transaction_id.3"})
    Table.TransformColumnTypes(#"Renamed Columns", {{"order_id", Int64.Type}})
    Table.AddColumn(#"Changed Type", "product_customer",
        each Text.Combine({Text.From([product_id]), [customer_code]}, "-"), type text)

    Int64.Type is a whole number; type number is a decimal.

    Common mistakes

    • Joining a number with &. Wrap it in Text.From( ) or change its type to text first.
    • Keeping all three split columns. The checker, like the person reading your table, only wants the order number.
    • Leaving order_id as text. It shows 008514, and a merge against the orders table finds nothing.
    • Splitting with a delimiter that also appears inside the data. A product name like Oak-Leaf Vase split by - lands in two columns. Check the values before you pick a delimiter.

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