Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JL0101
Helper I
Helper I

How do I transform this table ?

How would I convert this table 1 below using m code 

 

table 1

NRM Code          Version Date       Vol (Sum)           
02.01.04.0117/01/2023636.8166937
01.01.02.1217/01/2023730.9046459
02.02.01.0117/01/20237098.979422
02.03.01.0417/01/20232547.531327
01.01.02.1317/01/2023133.2549991
02.01.04.0217/01/20231830.027974
02.01.04.0317/01/20232108.871048
01.01.02.0417/01/20235486.499548
01.01.05.0117/01/20231898.504378
01.01.03.0117/01/20236038.022427
01.01.05.0617/01/202310090.45564
01.01.05.1817/01/20231188.122389
02.04.01.0117/01/202334.45970414
99.00.01.8817/01/20230
02.01.01.0117/01/202349.84026733
02.01.05.0117/01/202341.22312498
02.01.04.0125/01/2023291.1472298
01.01.02.1225/01/2023724.7269464
02.02.01.0125/01/20231918.890891
02.03.01.0425/01/2023839.113819
01.01.02.1325/01/2023132.4549991
02.01.04.0225/01/2023892.1064457
02.01.04.0325/01/2023729.7111469
01.01.02.0425/01/20232497.379227
99.00.01.8825/01/20230
01.01.05.0125/01/2023196.5305659
01.01.03.0125/01/2023432.447384
01.01.05.0625/01/20231217.279487
01.01.05.1825/01/2023201.7811789
02.04.01.0125/01/202337.79873231
02.01.01.0125/01/20235.0163181
02.01.05.0125/01/202320.4010378
02.01.04.0107/02/2023290.8027298
01.01.02.1207/02/2023724.7269464
02.02.01.0107/02/20231918.890891
02.03.01.0407/02/2023839.113819
01.01.02.1307/02/2023132.4549991
02.01.04.0207/02/2023892.1064461
02.01.04.0307/02/2023726.7576776
01.01.02.0407/02/20232497.379227
99.00.01.8807/02/20230
01.01.05.0107/02/2023196.5305659
01.01.03.0107/02/2023432.447384
01.01.05.0607/02/20231217.279487
01.01.05.1807/02/2023201.7811789
02.04.01.0107/02/202337.79873231
02.01.01.0107/02/20235.016318065
02.01.05.0107/02/202320.40528602

 

To table 2

 

NRM Code      17/01/2023       25/01/2023        07/02/2023                     
02.01.04.01636.81669291.14723290.80273
01.01.02.12730.90465724.72695724.72695
02.02.01.017098.97941918.89091918.8909
02.03.01.042547.5313839.11382839.11382
01.01.02.13133.255132.455132.455
02.01.04.021830.028892.10645892.10645
02.01.04.032108.871729.71115726.75768
01.01.02.045486.49952497.37922497.3792
01.01.05.011898.504400
01.01.03.016038.0224196.53057196.53057
01.01.05.0610090.456432.44738432.44738
01.01.05.181188.12241217.27951217.2795
02.04.01.0134.459704201.78118201.78118
99.00.01.88037.79873237.798732
02.01.01.0149.8402675.01631815.0163181
02.01.05.0141.22312520.40103820.405286

 

The items in the second table is the volume 

1 ACCEPTED SOLUTION
Syk
Super User
Super User

Select your version date > Pivot column
Select your volume as values and hit Ok.

Syk_0-1687981334615.png

 

View solution in original post

7 REPLIES 7
JL0101
Helper I
Helper I

Thanks all pivot worked

Sharma_Yash
Frequent Visitor

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.


 

JL0101
Helper I
Helper I

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?

Syk
Super User
Super User

Select your version date > Pivot column
Select your volume as values and hit Ok.

Syk_0-1687981334615.png

 

ronrsnfld
Super User
Super User

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.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors