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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
PowerWhy
Helper IV
Helper IV

Combining files with different field names from Sharepoint folder

Hello,

 

Please can you tell me how to combine files from the same sharepoint folder if these files have different field names? (and I don't know what field names will be added in the future). I'd like all fields to be present in the final table, with nulls where a field isn't present for a given input file.

 

Checking google and copilot for this seems to give very complicated solutions using direct M code editing, are there any 'standard' ways of working (I'd like to cross-train non-expert power bi users and they won't be able to code M code directly)

 

Thank you for your help!

 

CM

1 ACCEPTED SOLUTION

Hi @PowerWhy ,

 

To do this you need to change the last step of the query when you do the merge.

 

In my example I have 4 files all of them with different headers:

MFelix_0-1754037006135.png

 

The last step will expand the table and you get a similar result to this:

MFelix_1-1754037084286.png

 

Has you can see what is hapenning is that the "automatic" transformation forces only the columns from the first file to be expanded, you need to change the last part of the code:

MFelix_2-1754037149893.png

 

Replace the highlited part by 

List.Distinct(List.Combine(List.Transform (#"Removed Other Columns1"[Transform File],each Table.ColumnNames(_))))

So your full code will be:

= Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", List.Distinct(List.Combine(List.Transform (#"Removed Other Columns1"[Transform File],each Table.ColumnNames(_)))))

Has you can see now the result is expanding all the columns:

MFelix_3-1754037214479.png

Hope this helps if you need additional information please let me know.

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

10 REPLIES 10
V-yubandi-msft
Community Support
Community Support

Hi @PowerWhy ,

Could you let me know if your issue is resolved, or if you need any additional details.

Thanks.

V-yubandi-msft
Community Support
Community Support

Hello @PowerWhy ,

If your issue is resolved, that’s good to hear. But if you're still facing any difficulties or running into new challenges, feel free to let me know.

 

Thank You.

V-yubandi-msft
Community Support
Community Support

Hello @PowerWhy ,

Just checking in does @MFelix , response address your needs? If you need further assistance or clarification, please let us know. We're here to help.

 

Thanks.

Ashish_Mathur
Super User
Super User

Hi,

Watch this video to get started - Power Query #08: Import Multiple Excel Sheets From Multiple Excel Workbooks - YouTube


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

OK but I think the files in that video all have the same column structure within each worksheet?

Hi @PowerWhy ,

 

To do this you need to change the last step of the query when you do the merge.

 

In my example I have 4 files all of them with different headers:

MFelix_0-1754037006135.png

 

The last step will expand the table and you get a similar result to this:

MFelix_1-1754037084286.png

 

Has you can see what is hapenning is that the "automatic" transformation forces only the columns from the first file to be expanded, you need to change the last part of the code:

MFelix_2-1754037149893.png

 

Replace the highlited part by 

List.Distinct(List.Combine(List.Transform (#"Removed Other Columns1"[Transform File],each Table.ColumnNames(_))))

So your full code will be:

= Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", List.Distinct(List.Combine(List.Transform (#"Removed Other Columns1"[Transform File],each Table.ColumnNames(_)))))

Has you can see now the result is expanding all the columns:

MFelix_3-1754037214479.png

Hope this helps if you need additional information please let me know.

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @PowerWhy ,

 

This depends on the type of file you have and the settings.

 

Can you please give some additional information about the setup of the files, and how it can change in the future.

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi Felix,

 

For example:
File 1 may have column headers A, B, C

File 2 may have column headers A, C, D
So for these 2 files the output table should include column headers A, B, C, D

But there will be more files in the future and we don't know what column headers they will have, but they will also need including in the output file.

 

Does that make sense?

 

CM

What type of files are you working with? Csv, Excel, json


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Excel

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors