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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
As9124141636
Helper I
Helper I

unpivot automatically

I have an Excel file contains

 

 

 

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @As9124141636 ,

 

I think I found a solution.

I split the table into different years. Then I'm looping over each table and do the transformation.

 

Please check the attached file. When you open the Power BI file, you have to adapt the parameter "PathToXLSXFile" to the path and name of your XLSX file, for example to "C:\temp\Transpose.xlsx".

Afterwards the rest should load automatically.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

View solution in original post

4 REPLIES 4
selimovd
Super User
Super User

Hey @As9124141636 ,

 

I think I found a solution.

I split the table into different years. Then I'm looping over each table and do the transformation.

 

Please check the attached file. When you open the Power BI file, you have to adapt the parameter "PathToXLSXFile" to the path and name of your XLSX file, for example to "C:\temp\Transpose.xlsx".

Afterwards the rest should load automatically.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

Ashish_Mathur
Super User
Super User

Hi,

Why is your data in such a poor format?  Why not clean it up to atlest have all years listed down a single column and then upload the Data to PowerBI?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@As9124141636 , Having them in one sheet is not a good idea. Check if this code can help

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fZJLEgMhCETvMuss5NMCZ5nK/a8RGFNJqsK4QpQHbet5HnQ8DjIxWC7YY4yMgolKGdPrnIfQzIVD8Y3Px3lwlVEw39M+ERVZ3vkHlswMCNqMNh0eP/TMdnrRWscQ0blTTkLSDq8yUtiq7/HsbtHSNTNb80Xd0KKpvqXtkj5VNnQ+Crz3zS/faMRGucfsldeuiUI2o8EAtTSNdXHzjevp6fpO/3h1hdK62M1/CTLu6dp24uXqjXZVt+bFny8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"2011" = _t, A = _t, B = _t, C = _t, D = _t, E = _t, F = _t, G = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"2011", Int64.Type}, {"A", Int64.Type}, {"B", Int64.Type}, {"C", Int64.Type}, {"D", Int64.Type}, {"E", Int64.Type}, {"F", Int64.Type}, {"G", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"A", "B", "C", "D", "E", "F", "G"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Year"}, {"Value", "Month"}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Renamed Columns", {"Year", "Month"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

thanks

i think you did it for one year. i want to do for all years and if new year added in excel, transform it automatically.

I think the solution is create list of years and transform every year (in a loop) then finally append. but i dont know how to do in power query.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.