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
MrSplinter
Frequent Visitor

Tables for each file in folder, load header names from separate file

I have the following files:

- A folder with multiple .CSV-files. Each file might have a different number of columns. The header names are missing.

- A .CSV-files in this folder called Index.csv, which contains the names of the .csv-files and a row for each header-name (plus alias).

 

The number of files and their names might vary. The Index.csv always contains the names of all files and their headers.

What I want:
- Load all the files in the folder
- Create a table for each separate file

- Load the correct headers names for each table from the Index.csv file

- The solution should still work if the number of files and their names change

Is this possible in Power BI?

I could write a loop in Python, but that solution would require the client to locally install Python.

Actual data is confidential, so here are two examples with fake data but identical structure:


Example of the Index.csv file:

FilenameColumnNameColumnAlias
City.csvPostalCodePC
City.csvLongitudeLong
City.csvLatitudeLat
Inhabitants.csvCityCity
Inhabitants.csvNumberNo

 

Example of a random file (City.csv):

London52.84845.5404
Berlin49.30304.3030
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @MrSplinter

 

I'm afraid this step "- Create a table for each separate file" cannot be done with Power Query. Power Query cannot create queries according to file names automatically. Queries need to be created by you manually. So the number of queries is fixed before any refresh. 

 

The closest result I can achieve with Power Query is like below. I can get the table you want for every file row. However, I'm not able to split this column into multiple queries (tables) automatically as Power Query doesn't support that. I have attached the sample file for your reference. 

vjingzhang_0-1671007878515.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @MrSplinter

 

I'm afraid this step "- Create a table for each separate file" cannot be done with Power Query. Power Query cannot create queries according to file names automatically. Queries need to be created by you manually. So the number of queries is fixed before any refresh. 

 

The closest result I can achieve with Power Query is like below. I can get the table you want for every file row. However, I'm not able to split this column into multiple queries (tables) automatically as Power Query doesn't support that. I have attached the sample file for your reference. 

vjingzhang_0-1671007878515.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

Helpful resources

Announcements
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.

Top Kudoed Authors