Forum Discussion
power query add column with file name
- Dec 06, 2021
That's bit hard to do since I don't recognize names you use. If by steps:
Check generated master query which shall be in Other Queries
find Removed Other Columns1 step and click on gear.
Transform File column is always selected, select Source.Name and, if necessary, any other column(s) with file metadata. Click Ok.
Please note, Power Query could add this column automatically. Perhaps depends on version, not 100% sure.
juan jimenez When you connect to a folder and load the data for the first time, PQ creates some helper queries and a function that contains the necessary steps to connect to each file in the folder (in simple terms). The main query connects to the specified folder and and invokes (executes) the function and expands the data from each table into one larger table.
The first column is called "Source.Name" (in English) and contains the name of the source file. So if you do not delete that column the file name is part of the data set.
Thank you very much for the answer and explanation.
I have not deleted the file name column but when I get the data from the files and I cannot see in column with that file name.
What instructions should I use in order to get the file named into the final chart?
Thank you, Juan
- SergeiBaklanDec 06, 2021MVP
Check you script. After Invoke Custom Function step script automatically adds Remove Other Columns. It removes all columns but Transform File one. Manually add Name column to the selection.
- Riny_van_EekelenDec 06, 2021Platinum Contributor
juan jimenez Sorry! Can't help without access to your system.
- juan jimenezDec 06, 2021Iron ContributorIs it not possible to add a line to the above commands show that the file name appears in the final data?
If this is the case, could it be possible that I sent the Excel with the power query? How?
Thanks, juan- SergeiBaklanDec 06, 2021MVP