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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
KobeDel
Frequent Visitor

Transforming data from 1 date row with lots of columns to different date rows with less columns

Hello,

 

I have a dataset like this. But with a lot more columns. At this moment, there is in the column name, the machine name and the categorie. Machine name is always 3 characters.

 AG5 startupAG7 startupML1 startupAG5 foldingAG7 foldingML1 folding
1/05/20255030010300
2/05/2025201035354520
3/05/202585653524360
4/05/202548876189140
5/05/202514672524210

 

I want to transform it like this, so that it is more easy to make a power bi dashboard from it with filters and categories.

Any tips on how to handle/start this transformation? Many thanks in advance.

 

 kgmachinecategorie
1/05/202550AG5startup
1/05/202530AG7startup
1/05/202510AG5folding
1/05/202530AG7folding
2/05/202520AG5startup
2/05/202510AG7startup
2/05/202535ML1startup
2/05/202535AG5folding
2/05/202545AG7folding
2/05/202520ML1folding
   
1 ACCEPTED SOLUTION
p45cal
Super User
Super User

See attached a basic start:

 

p45cal_0-1748860418577.png

 

Code:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc3BDcAgCAXQXTybCAjWzmLcf436bSsc/AF94BiJuJAVIbGUk9GKisDh0M28qAQqLuwP/R42rgF3RDtOFFXzxRqsdgxcGGBUN/5Rtxbsvm+wcvYKv3Y+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"AG5 startup" = _t, #"AG7 startup" = _t, #"ML1 startup" = _t, #"AG5 folding" = _t, #"AG7 folding" = _t, #"ML1 folding" = _t]),
    CT = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    UnpivotOtherColumns = Table.UnpivotOtherColumns(CT, {"Date"}, "Attribute", "kg"),
    SplitColumn = Table.SplitColumn(UnpivotOtherColumns, "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Machine", "categorie"}),
    CT2 = Table.TransformColumnTypes(SplitColumn,{{"kg", type number}}),
    Filter = Table.SelectRows(CT2, each ([kg] <> 0)),
    ReOrderolumns = Table.SelectColumns(Filter,{"Date", "kg", "Machine", "categorie"})
in
    ReOrderolumns

View solution in original post

2 REPLIES 2
KobeDel
Frequent Visitor

Didn't know it was that easy. Thank you very much for the fast response!!

p45cal
Super User
Super User

See attached a basic start:

 

p45cal_0-1748860418577.png

 

Code:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc3BDcAgCAXQXTybCAjWzmLcf436bSsc/AF94BiJuJAVIbGUk9GKisDh0M28qAQqLuwP/R42rgF3RDtOFFXzxRqsdgxcGGBUN/5Rtxbsvm+wcvYKv3Y+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"AG5 startup" = _t, #"AG7 startup" = _t, #"ML1 startup" = _t, #"AG5 folding" = _t, #"AG7 folding" = _t, #"ML1 folding" = _t]),
    CT = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    UnpivotOtherColumns = Table.UnpivotOtherColumns(CT, {"Date"}, "Attribute", "kg"),
    SplitColumn = Table.SplitColumn(UnpivotOtherColumns, "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Machine", "categorie"}),
    CT2 = Table.TransformColumnTypes(SplitColumn,{{"kg", type number}}),
    Filter = Table.SelectRows(CT2, each ([kg] <> 0)),
    ReOrderolumns = Table.SelectColumns(Filter,{"Date", "kg", "Machine", "categorie"})
in
    ReOrderolumns

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors