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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

How to add a new column with file source name

Hi Community,

can you help me with this issue??

i want to add a new column in my appended / merge table showing the name of the file that the raws come from.


Regards

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

1. If you are connecting to these excel files directly, then you may have to use parameters to enter the path of the excel files. As shown below, create parameters for each excel files, and the parameter value is the path to the corresponding excel file, which can then be referenced in the data source to import the excel table. 

 

vkkfmsft_5-1640155221153.png

Source = Excel.Workbook(File.Contents(#"Excel1 path"), null, true)
Source = Excel.Workbook(File.Contents(#"Excel2 path"), null, true)

vkkfmsft_8-1640155401074.png  vkkfmsft_7-1640155358688.png

 

Then create the following custom columns for each table, i.e. the column value is equal to the parameter value. Then split the column to get the file name.

 

vkkfmsft_9-1640155436381.png

vkkfmsft_10-1640155508890.png

vkkfmsft_11-1640155559172.png

vkkfmsft_12-1640155580076.png

 

2. A simpler way is to put all excel files in the same folder and then use the Folder connector, which will include the name and path of each excel file. 

 

vkkfmsft_0-1640152894592.png

vkkfmsft_4-1640155167811.png

 

If the excel files you want to append have the same structure, then you can just click on "Combine Files" and you will get the following result.

vkkfmsft_3-1640153035503.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

This is the result of directly append queries. 

 

vkkfmsft_0-1639965150156.png

 

You can try adding custom columns to add the paths to each table, or you can also refer to this video to create your functions.

 

= Table.Combine({Table.AddColumn(#"Changed Type","FileName",each "Table A"), Table.AddColumn(#"Table B","FileName",each "Table B")})

vkkfmsft_1-1639965193066.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

HI, thanks for your response, but it is not usefull

as i need the filename ( excell file name) into a custom column

 

Thanks

lbendlin
Super User
Super User

Yes, this is possible. Please provide more details about your setup, and maybe some sample files.

Anonymous
Not applicable

need to add in this custom column

PedroYondr_0-1639998527629.png

 

the name of the excel file

PedroYondr_1-1639998598132.png

 

thanks

Hi @Anonymous ,

 

1. If you are connecting to these excel files directly, then you may have to use parameters to enter the path of the excel files. As shown below, create parameters for each excel files, and the parameter value is the path to the corresponding excel file, which can then be referenced in the data source to import the excel table. 

 

vkkfmsft_5-1640155221153.png

Source = Excel.Workbook(File.Contents(#"Excel1 path"), null, true)
Source = Excel.Workbook(File.Contents(#"Excel2 path"), null, true)

vkkfmsft_8-1640155401074.png  vkkfmsft_7-1640155358688.png

 

Then create the following custom columns for each table, i.e. the column value is equal to the parameter value. Then split the column to get the file name.

 

vkkfmsft_9-1640155436381.png

vkkfmsft_10-1640155508890.png

vkkfmsft_11-1640155559172.png

vkkfmsft_12-1640155580076.png

 

2. A simpler way is to put all excel files in the same folder and then use the Folder connector, which will include the name and path of each excel file. 

 

vkkfmsft_0-1640152894592.png

vkkfmsft_4-1640155167811.png

 

If the excel files you want to append have the same structure, then you can just click on "Combine Files" and you will get the following result.

vkkfmsft_3-1640153035503.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors