Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
How would I convert this table 1 below using m code
table 1
| NRM Code | Version Date | Vol (Sum) |
| 02.01.04.01 | 17/01/2023 | 636.8166937 |
| 01.01.02.12 | 17/01/2023 | 730.9046459 |
| 02.02.01.01 | 17/01/2023 | 7098.979422 |
| 02.03.01.04 | 17/01/2023 | 2547.531327 |
| 01.01.02.13 | 17/01/2023 | 133.2549991 |
| 02.01.04.02 | 17/01/2023 | 1830.027974 |
| 02.01.04.03 | 17/01/2023 | 2108.871048 |
| 01.01.02.04 | 17/01/2023 | 5486.499548 |
| 01.01.05.01 | 17/01/2023 | 1898.504378 |
| 01.01.03.01 | 17/01/2023 | 6038.022427 |
| 01.01.05.06 | 17/01/2023 | 10090.45564 |
| 01.01.05.18 | 17/01/2023 | 1188.122389 |
| 02.04.01.01 | 17/01/2023 | 34.45970414 |
| 99.00.01.88 | 17/01/2023 | 0 |
| 02.01.01.01 | 17/01/2023 | 49.84026733 |
| 02.01.05.01 | 17/01/2023 | 41.22312498 |
| 02.01.04.01 | 25/01/2023 | 291.1472298 |
| 01.01.02.12 | 25/01/2023 | 724.7269464 |
| 02.02.01.01 | 25/01/2023 | 1918.890891 |
| 02.03.01.04 | 25/01/2023 | 839.113819 |
| 01.01.02.13 | 25/01/2023 | 132.4549991 |
| 02.01.04.02 | 25/01/2023 | 892.1064457 |
| 02.01.04.03 | 25/01/2023 | 729.7111469 |
| 01.01.02.04 | 25/01/2023 | 2497.379227 |
| 99.00.01.88 | 25/01/2023 | 0 |
| 01.01.05.01 | 25/01/2023 | 196.5305659 |
| 01.01.03.01 | 25/01/2023 | 432.447384 |
| 01.01.05.06 | 25/01/2023 | 1217.279487 |
| 01.01.05.18 | 25/01/2023 | 201.7811789 |
| 02.04.01.01 | 25/01/2023 | 37.79873231 |
| 02.01.01.01 | 25/01/2023 | 5.0163181 |
| 02.01.05.01 | 25/01/2023 | 20.4010378 |
| 02.01.04.01 | 07/02/2023 | 290.8027298 |
| 01.01.02.12 | 07/02/2023 | 724.7269464 |
| 02.02.01.01 | 07/02/2023 | 1918.890891 |
| 02.03.01.04 | 07/02/2023 | 839.113819 |
| 01.01.02.13 | 07/02/2023 | 132.4549991 |
| 02.01.04.02 | 07/02/2023 | 892.1064461 |
| 02.01.04.03 | 07/02/2023 | 726.7576776 |
| 01.01.02.04 | 07/02/2023 | 2497.379227 |
| 99.00.01.88 | 07/02/2023 | 0 |
| 01.01.05.01 | 07/02/2023 | 196.5305659 |
| 01.01.03.01 | 07/02/2023 | 432.447384 |
| 01.01.05.06 | 07/02/2023 | 1217.279487 |
| 01.01.05.18 | 07/02/2023 | 201.7811789 |
| 02.04.01.01 | 07/02/2023 | 37.79873231 |
| 02.01.01.01 | 07/02/2023 | 5.016318065 |
| 02.01.05.01 | 07/02/2023 | 20.40528602 |
To table 2
| NRM Code | 17/01/2023 | 25/01/2023 | 07/02/2023 |
| 02.01.04.01 | 636.81669 | 291.14723 | 290.80273 |
| 01.01.02.12 | 730.90465 | 724.72695 | 724.72695 |
| 02.02.01.01 | 7098.9794 | 1918.8909 | 1918.8909 |
| 02.03.01.04 | 2547.5313 | 839.11382 | 839.11382 |
| 01.01.02.13 | 133.255 | 132.455 | 132.455 |
| 02.01.04.02 | 1830.028 | 892.10645 | 892.10645 |
| 02.01.04.03 | 2108.871 | 729.71115 | 726.75768 |
| 01.01.02.04 | 5486.4995 | 2497.3792 | 2497.3792 |
| 01.01.05.01 | 1898.5044 | 0 | 0 |
| 01.01.03.01 | 6038.0224 | 196.53057 | 196.53057 |
| 01.01.05.06 | 10090.456 | 432.44738 | 432.44738 |
| 01.01.05.18 | 1188.1224 | 1217.2795 | 1217.2795 |
| 02.04.01.01 | 34.459704 | 201.78118 | 201.78118 |
| 99.00.01.88 | 0 | 37.798732 | 37.798732 |
| 02.01.01.01 | 49.840267 | 5.0163181 | 5.0163181 |
| 02.01.05.01 | 41.223125 | 20.401038 | 20.405286 |
The items in the second table is the volume
Solved! Go to Solution.
Select your version date > Pivot column
Select your volume as values and hit Ok.
Thanks all pivot worked
Hey @JL0101 ,
Copy the following code in Advanced editor:-
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fZRZbuswDEX3ku+C5SQOaymy/208pmnTUObTjwHDB1ccjvz1dUMGJECt5+3jRv6J9MnIUi8mBkFmKX67fxRK3ygD8Y66ICSq6conyvATfEl1zID0VOYXKs8adpSXOiwh4b0A2VESgcIzk16pz7YutVJUscierht6SWXCgHBCjV7AtdalYVDnr46uYQIUNYGFKt5QmVaAEnUea59ApdolFTERdC3TjlJcUIqoJbLE37Z03pZoRaaj0jM1ExAfaFxS8X2aU5YmhCKbi7yj04iUoMoj1oxtR/TtxfuOkoDUmTMGSxvqrOBsqaaDpQ2lpNp8Yrz59GdpQ0MSiCQoB0l7qHBN83+S9tCsADTV5YOkW1cJTkRqOUjaZ6XpIJ78o1PfZkNxsHibkNXdxGUrB4sbqo++1SV0kLiHMjnU1dTwQeLeS33wIPJR4oaKg2e4lFGDow19dGpCQYOh2/GgSPi6w01QLJf5T1CEqP/NLGhDz4I29CxoQ4+C9tCjoD30V1Db0UtqdQS+3NxtELTP6ihoQydBtwmdBG3oUdAeehS093IUtKFnQRv6KyjaGhTdCihFF4fV9u73fw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"NRM Code " = _t, #"Version Date " = _t, #"Vol (Sum) " = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"NRM Code ", type text}, {"Version Date ", type text}, {"Vol (Sum) ", type number}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#"Version Date "]), "Version Date ", "Vol (Sum) ", List.Sum)
in
#"Pivoted Column"
-If you get the output, then mark my post as solutions.
When I carryout the pivot function it works if I limit the row number to 150 but for the acctualy size of the table I get the following error
Expression.Error: There were too many elements in the enumeration to complete the operation.
Details:
[List]
Are you certain you are using "Sum" for the Pivot Aggregation as shown in the screenshot?
Select your version date > Pivot column
Select your volume as values and hit Ok.
It looks like a pivot. But your numbers don't add up. What algorithm are you using to obtain the values in Table 2 from the data in Table1?
eg. in Table 1 NRM 1.1.2.12 on 17/01/2023 has a value of 730.9. But in your table 2, it shows 1563.41
Ah yes I have corrected that now they should be the same.
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 11 | |
| 11 | |
| 5 | |
| 4 | |
| 4 |