Hi,
In the example below I have a text description field that is split/spilled over 3 rows, and also a 4 columns of numbers that need to be on the same row.
What's the best way to transform the table so that the rows are merged? Should it be some sort of next unpivot?
In the example below I have a text description field that is split/spilled over 3 rows, and also a 4 columns of numbers that need to be on the same row.
What's the best way to transform the table so that the rows are merged? Should it be some sort of next unpivot?
Tax Calcs to 5 Apr2024.xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | From this: | ||||||||
2 | Date of Sale | Sale Quantity | Stock, Matching Details | Proceeds | Cost | Net Loss | Net Gain | ||
3 | 14/11/2023 | 35 | ADVANCED MICRO DEVICES INC | ||||||
4 | COM STK USD0.01 | 3341.21 | |||||||
5 | 08 Pool of 35 | 2508.59 | 832.62 | ||||||
6 | 14/11/2023 | 134 | APPLE INC | ||||||
7 | COM USD0.00001 | 19997.59 | |||||||
8 | 08 Pool of 134 | 2423.16 | 17574.43 | ||||||
9 | 21/02/2024 | 2500 | ATOME PLC | ||||||
10 | ORD GBP0.002 (AIM) | 1252.55 | |||||||
11 | 08 Pool of 2,500 | 2000 | 747.45 | ||||||
12 | 21/07/2023 | 59 | BEYOND MEAT | ||||||
13 | USD0.0001 | 679 | |||||||
14 | 08 Pool of 59 | 5044.67 | 4365.67 | ||||||
15 | |||||||||
16 | |||||||||
17 | To this: | ||||||||
18 | Date of Sale | Sale Quantity | Stock, Matching Details | Proceeds | Cost | Net Loss | Net Gain | ||
19 | 14/11/2023 | 35 | ADVANCED MICRO DEVICES INC COM STK USD0.01 08 Pool of 35 | 3341.21 | 2508.59 | 832.62 | |||
20 | 14/11/2023 | 134 | APPLE INC COM USD0.00001 08 Pool of 134 | 19997.59 | 2423.16 | 17574.43 | |||
21 | 21/02/2024 | 2500 | ATOME PLC ORD GBP0.002 (AIM) 08 Pool of 2,500 | 1252.55 | 2000 | 747.45 | |||
22 | 21/07/2023 | 59 | BEYOND MEAT USD0.0001 08 Pool of 59 | 679 | 5044.67 | 4365.67 | |||
Table008 (Page 16) (2) |
Power Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZFNa4QwEIb/yuCpBclmJhOjR1dDka4frHahiNeeCv7/WzOmthQqhiG8QzIzT97Mc4J8QbyQJpOkibFhK+tH2VW+hrap7j3U/tFUfoSmq8Lhbyzp/C2rvoVxeoW3sdZKo/QxjIrwv8s6h2FdP2H9gG1aCLI6V7aISW5IZbQV/EFDw8I2DDd/ghIxwpL5WBSF+2l+iBK7CwuTUZjFBJ11rNhsNYQXTULDEVkLztS3HobbEU5/r+HlOggOwVPZtM/SlSwpa0+IKI0jZJjelGOn2O4FguN2c7b3Xf1734Vf8+V0gLM7I8Zk7syT3TSrmVXmgmKT2aiSZfkC", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date of Sale" = _t, #"Sale Quantity" = _t, #"Stock, Matching Details" = _t, Proceeds = _t, Cost = _t, #"Net Loss" = _t, #"Net Gain" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date of Sale", type date}, {"Sale Quantity", Int64.Type}, {"Stock, Matching Details", type text}, {"Proceeds", type number}, {"Cost", type number}, {"Net Loss", type number}, {"Net Gain", type number}})
in
#"Changed Type"