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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
PowerBeeEye
Microsoft Employee
Microsoft Employee

Promote headers within Csv.Document

I have multiple CSV files I am trying to combine in a query.

I am trying to do this without a function.

Two issues I am running into:

  • Empty cells - these throw the next row out of what. I was able to get around this by specifying the quotestyle
    • = Csv.Document(Transform_Preferences_Registry_Parameter,[Delimiter=",", Columns=36, Encoding=1252, QuoteStyle=QuoteStyle.Csv])
  • Some of the CSV files do not have a column that is present in the others. When combining, this messes up the resulting table
    • The only way I can see to workaround this is to promote the headers.

Is there a way I can promote headers for each CSV file before combining them without using a function, and within the same query?

4 REPLIES 4
IvanRy
New Member

Maybe it will be helpful for other people, just wrap yor Csv.Document() with Table.PromoteHeaders like this:
= Table.AddColumn(#"Removed Other Columns", "Custom", each Table.PromoteHeaders(Csv.Document([Content])))
Csv.Documents.jpg

This is the correct answer.

mussaenda
Super User
Super User

Hi @PowerBeeEye ,

 

Have you checked this link out?

 https://youtu.be/mg_qLIQjjaM

 

It helped me to solve my problem but I eventually used the function instead of this.

But this might help you on your situation.

 

Hope this helps!

mahoneypat
Microsoft Employee
Microsoft Employee

Why trying to avoid using a function?  It is the way to do this one.  You can create the function within the same query if needed.

 

Also, you can use Csv.Document to get your column of tables (one for each file), and then use a table function to remove the top row of each before expand/append the tables (but maybe it is too late by then?).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.