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
Lara137
New Member

Power BI : data transformation with Power query

Hello everyone!

 

I'm new in Power BI and should to transform data in Power query for convinient analizing.

I need to have one column for date (years), one column for Units and one column for sales, EUR. 

I tried to Unpivot columns, but didn't get the needed result.

 

Could you please advise some aproach? 

 

Thank you in advance!

 

Here is the part od data.

 

Sku name    Quarter       2019, Units          2019, EUR              2020, Units            2020, EUR

5_SKU            Q1                 253                   825                           0                        0

5_SKU            Q2                 125                    569                          0                         0

5_SKU            Q3                   89                    425                          0                         0

5_SKU            Q4                    98                    657                         0                          0

5_SKU            Q1                    0                        0                         124                     985

5_SKU            Q2                     0                       0                          98                      741

5_SKU            Q3                     0                      0                           74                      695

5_SKU            Q4                     0                      0                           97                      954

1 ACCEPTED SOLUTION
spinfuzer
Solution Sage
Solution Sage

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dY4xDoAgDEXv0pnBYgv0DE7GOBHi/W9hWwMxQQfeQF9/f63A17GdEGBHReRVWSIrF38tvJSoQB9ykm/F921GfyGkkKJInL8NHN927vF5btIVD8uEc5FuZMtIwnORkWFVhAlauwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sku name" = _t, Quarter = _t, #"2019, Units" = _t, #"2019, EUR" = _t, #"2020, Units" = _t, #"2020, EUR" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Sku name", type text}, {"Quarter", type text}, {"2019, Units", Int64.Type}, {"2019, EUR", Int64.Type}, {"2020, Units", Int64.Type}, {"2020, EUR", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Sku name", "Quarter"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", Int64.Type}, {"Attribute.2", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.2]), "Attribute.2", "Value", List.Sum)
in
    #"Pivoted Column"

 

Copy and paste the full example into your advanced editor.

View solution in original post

1 REPLY 1
spinfuzer
Solution Sage
Solution Sage

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dY4xDoAgDEXv0pnBYgv0DE7GOBHi/W9hWwMxQQfeQF9/f63A17GdEGBHReRVWSIrF38tvJSoQB9ykm/F921GfyGkkKJInL8NHN927vF5btIVD8uEc5FuZMtIwnORkWFVhAlauwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sku name" = _t, Quarter = _t, #"2019, Units" = _t, #"2019, EUR" = _t, #"2020, Units" = _t, #"2020, EUR" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Sku name", type text}, {"Quarter", type text}, {"2019, Units", Int64.Type}, {"2019, EUR", Int64.Type}, {"2020, Units", Int64.Type}, {"2020, EUR", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Sku name", "Quarter"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", Int64.Type}, {"Attribute.2", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.2]), "Attribute.2", "Value", List.Sum)
in
    #"Pivoted Column"

 

Copy and paste the full example into your advanced editor.

Helpful resources

Announcements
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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