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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
AndreWahlbuhl
Frequent Visitor

How to treat table with stacked data

Hello fellows!  I know you are advanced guys and I have a simple user question that is making me crazy.

 

I have tons of files in CSV to be treated on PowerQuery. The problem that the data on that files is stacked. I dont know how to treat them on Power Query. I dont know how to separate the data in lines to rows having in mind that a single line corresponds a 4 lines of date on the original table. 

 

I´m attaching a PDF extraction of that table. 

 

I dont use Excel to treat them because the idea is to make it an process, reading such a dump folder and creating such a incremental dashboard.

 

Thanks a lot for your help.

 

 Stacked Data Tabel.png

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @AndreWahlbuhl 

 

I don't know how the document header is structured and if you need this information somehow too. I assume that you have anonymous column header and then stacked information whereas one row is structured in 3 rows like this. In case you have a document header, you would need somehow to eliminate your header (by deleteing the first rows or by checking one of your column until a certain value is reached - maybe "Name" in column1

 

Jimmy801_0-1609860930153.png

 

In this case you can split the table with pagesize 3 and then transform the list of tables by referencing the column and the row. After that the records can be transformed to a table. Would you need also something of your document header, you could now add an additional column where you referencing your first step.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY+7CsMwDEV/RXgOwXGW0rnN2KFJJ5PBUEEMrh0kJdC/b+I+SDsVNIhzH0jWqpO7oSrUZ1pxMnFecGTVF3ZFJHhdWOOj5yGv5ylC53P2gGNId7gw0qtmTR2JEm2b38Lq09UWN86HXJp1U5eVKY02GvRub8zC/0MdsrRI89cZz26QBIScwowwJBaIP29ne/8A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t]),
    SplitTable = Table.Split(Source,3),
    TransformListsOfTables = List.Transform
    (
        SplitTable,
        each [1= [Column1]{0}, 2= [Column5]{0}, 3= [Column6]{0}, 4= [Column1]{1}, 5= [Column2]{1}, 6= [Column3]{1}, 7= [Column4]{1}, 8= [Column1]{1}]
    ), 
    CreateTableFromRecords= Table.PromoteHeaders(Table.FromRecords(TransformListsOfTables))
in
    CreateTableFromRecords

 

this is the outcome

Jimmy801_1-1609861088512.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

 

View solution in original post

3 REPLIES 3
Jimmy801
Community Champion
Community Champion

Hello @AndreWahlbuhl 

 

I don't know how the document header is structured and if you need this information somehow too. I assume that you have anonymous column header and then stacked information whereas one row is structured in 3 rows like this. In case you have a document header, you would need somehow to eliminate your header (by deleteing the first rows or by checking one of your column until a certain value is reached - maybe "Name" in column1

 

Jimmy801_0-1609860930153.png

 

In this case you can split the table with pagesize 3 and then transform the list of tables by referencing the column and the row. After that the records can be transformed to a table. Would you need also something of your document header, you could now add an additional column where you referencing your first step.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY+7CsMwDEV/RXgOwXGW0rnN2KFJJ5PBUEEMrh0kJdC/b+I+SDsVNIhzH0jWqpO7oSrUZ1pxMnFecGTVF3ZFJHhdWOOj5yGv5ylC53P2gGNId7gw0qtmTR2JEm2b38Lq09UWN86HXJp1U5eVKY02GvRub8zC/0MdsrRI89cZz26QBIScwowwJBaIP29ne/8A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t]),
    SplitTable = Table.Split(Source,3),
    TransformListsOfTables = List.Transform
    (
        SplitTable,
        each [1= [Column1]{0}, 2= [Column5]{0}, 3= [Column6]{0}, 4= [Column1]{1}, 5= [Column2]{1}, 6= [Column3]{1}, 7= [Column4]{1}, 8= [Column1]{1}]
    ), 
    CreateTableFromRecords= Table.PromoteHeaders(Table.FromRecords(TransformListsOfTables))
in
    CreateTableFromRecords

 

this is the outcome

Jimmy801_1-1609861088512.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works. 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

 

AlB
Community Champion
Community Champion

Hi @AndreWahlbuhl 

Can you:

1. Share a couple of the files you need to process

2. Very importantly: for one for those files, show the expected result after processing in PQ

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Cheers 

 

SU18_powerbi_badge

Sorry, I could´t post anything mothe than that. It is property of the company. 

but Im very thankful you helped me a lot guys!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.