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
AdrianJ
Regular Visitor

Transform a CSV file in Power Query where column headers are in separate columns from the values

Hey folks,

 

I've tried to figure this out myself and searched everywhere for a solution, to no avail. I am exporting reports in CSV format from Microsoft Dynamics 2016 and it outputs the report data in a very annoying format:

 

Table0_Header0,Table0_Header2,Table0_Header4,Table0_Header5,Table0_Details0,Table0_Details2,Table0_Details4,Table0_Details5
Name,Age,Gender,Location,John Doe,23,Male,Someplace
Name,Age,Gender,Location,Mary Sue,49,Female,Nowhere
Name,Age,Gender,Location,Bob Joans,37,Male,Outhere

 

 

How do I convert this structure into a sensible table programtically using Power Query? Like so:

NameAgeGenderLocation
John Doe23MaleSomeplace
Mary Sue49FemaleNowhere
Bob Joans37MaleOuthere

 

I have a lot of reports that are exported so the solution needs to work for different numbers of Header+Details sets, e.g., there could be 4 header+details sets (like here), or 8, or 20, etc. 

 

1 ACCEPTED SOLUTION
amustafa
Solution Sage
Solution Sage

Hi @AdrianJ , See the Solution in the attached .pbix file. Look at the Power Query section for transformation steps. I seperated the headers and details then appended the detail rows to header. This should work for any number of columns you may have in your output files.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
amustafa
Solution Sage
Solution Sage

Hi @AdrianJ , See the Solution in the attached .pbix file. Look at the Power Query section for transformation steps. I seperated the headers and details then appended the detail rows to header. This should work for any number of columns you may have in your output files.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Fantastic amustafa, thank you very much!

 

Splitting it out in a Header table and Detail table and then recombining it was an inspired approach. Thank you again for the help :).

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.