Power query - source file name i the table

Donbozone

New Member
Joined
Mar 28, 2020
Messages
45
Office Version
  1. 365
Platform
  1. Windows
Hi.

I need to combine several excel files into one and I do not have a problem to do that, but there is one thing that makes me a problem.

I want to have source file name in the table, which i made to do, but next time when I want to change source folder to pick up new data, it looks for that column considering it as part of the table and reports me with error.

There must be a solution for this..Thanks
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I've managed to resolve the problem. The problem accours after applying step called Used first row as header. At that moment Source.Name column gets renamed and Excel is trying to find that column unsuccesfully.
I found a solution, but that led me to another, let say a problem. There is no an option to use first row as header only for specific columns, so I had to rename one by one, all of them except the column Source.Name
After that the problem was resolved, manual renaming took some time.
 
Upvote 0
maybe easier will be if you rename Source.Name column each time after Table.PromoteHeaders
 
Upvote 0
I've tried that and it did not work. Not sure why, but I guess that query repeats each step when pulling data from new source. In some of these steps it finds this column under different name and returns error. Perhaps I did something wrong because it was expected to work just as you described.
 
Upvote 0
you can try
= Table.RenameColumns(Source,{{Table.ColumnNames(Source){0}, "Src.Name"}})
just after source line
I assumed Source.Name column is the first column and new name will be Src.Name
adapt to your needs

hard to say something more if I don't know source data, structure and M

note: or use it as a third line after Promote
Power Query:
let
   Source =...
   Promote =...
   Rename = line from above with Promote instead of Source
//and so on

in
   something
 
Last edited:
Upvote 0
I have set it already to work, but will give a try one of these, Im curious to see what is going to happen. Maybe will get a time tonight to check. Thanks
 
Upvote 0
Yes, it does the job. If I understood well, the zero denies previous change and revert it back, so it's like change has never happend, right?
 
Upvote 0
no, 0 is a column number
if you have "3" columns, for PQ it is 0, 1, 2
Power Query counting from 0 not from 1
 
Upvote 0

Forum statistics

Threads
1,223,762
Messages
6,174,357
Members
452,558
Latest member
jswan83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top