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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
abderrazak
Frequent Visitor

Pivot Multiple Columns in Power BI

Hi everyone 

i need to pivot this table in power bi and got this result : 

 

abderrazak_0-1636925458531.png

 

the original table is a input file : Excel 

abderrazak_1-1636925548490.png

 

thanks in advance 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Please follow steps below:

 

1. Unpivot all values columns.

2. Pivot the date column.

Vlianlmsft_0-1637126078193.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZDNCoAwCIDfZecCf+Zq5zoFQffR+79GapcKKwbq5FO+rbW0IkDq0rxNqImAsNdjLc6iEYtkTZD27g22OrPD5wzp5YYvV9zKWjTWMtokwAdsLSlOM//SbuJbn9oYv1FkDLUD3HdjjbwDmt69A9oIZjk/xZUIBh3YDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Code article" = _t, Division = _t, Date = _t, Consommation = _t, #"Couverture 1%" = _t, #"Livraison Prevue" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code article", type text}, {"Division", type text}, {"Date", type date}, {"Consommation", Int64.Type}, {"Couverture 1%", Int64.Type}, {"Livraison Prevue", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date", "Division", "Code article"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US")[Date]), "Date", "Value", List.Sum)
in
    #"Pivoted Column"

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Please follow steps below:

 

1. Unpivot all values columns.

2. Pivot the date column.

Vlianlmsft_0-1637126078193.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZDNCoAwCIDfZecCf+Zq5zoFQffR+79GapcKKwbq5FO+rbW0IkDq0rxNqImAsNdjLc6iEYtkTZD27g22OrPD5wzp5YYvV9zKWjTWMtokwAdsLSlOM//SbuJbn9oYv1FkDLUD3HdjjbwDmt69A9oIZjk/xZUIBh3YDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Code article" = _t, Division = _t, Date = _t, Consommation = _t, #"Couverture 1%" = _t, #"Livraison Prevue" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code article", type text}, {"Division", type text}, {"Date", type date}, {"Consommation", Int64.Type}, {"Couverture 1%", Int64.Type}, {"Livraison Prevue", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date", "Division", "Code article"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Unpivoted Other Columns", {{"Date", type text}}, "en-US")[Date]), "Date", "Value", List.Sum)
in
    #"Pivoted Column"

thank u so much

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.