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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
trickdigger
New Member

Power Query add custom column with name and merge all files

Hi, 

 

I am new to PowerBI/Power Query and was trying to solve this problem. 

 

I have a folder of files that contain data, but these files do not contain a column that indicates what product it is for. What I'm trying to do is add a column with the file name and the combine all of the files so that I have one table. 

 

I.E, my files are located in c:\files and are named:

  1. Product1.txt
  2. Product2.txt
  3. Product3.txt
  4. Product4.txt

I need to add a column to each file that says "Product1", for example, so that the product can be distinguised after the files are combined. Ideally this would be able to be automated so that the new files are dropped in and then refreshed. 

 

Could someone get me started? I searched for similar threads and I ended up getting lost trying to recreate the steps. 

 

Thanks

2 REPLIES 2
BhaveshPatel
Super User
Super User

Check out this recent blog post from Gil Raviv on PowerPivotPro.com

https://www.powerpivotpro.com/2016/12/import-csv-files-folder-filenames-power-bi/

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Bhavesh,

 

I tried it and it works, but I can't export the rows due to data limit. So I really need to do this in Power Query as the end users need the data in a pivoted excel file.

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.