Forum Discussion
Transform Sample File: Add Column>Custom Column to add "File Name"
- 3 years ago
Hi ryan1919
Here is an alternative solution. You need to create a "Transform Sample File" function manually instead of using the function & queries generated automatically by Combining binary column [Content].
First connect to a CSV file using Text/CSV connector. Treat it as a sample file and transform it per your need. For example, below is my sample query Jan (sample file).
Duplicate the sample query, then modify its code like below. I convert this query into a custom function with two parameters FileName and FolderPath. These paramters are used to connect to a CSV file and FileName is used to add a custom column which displays the file name.
Then connect to the folder using Folder connector. On the Source step, remove other columns except [Name] and [Folder Path]. Invoke the custom function created earlier to add a column. Use [Name] and [Folder Path] to provide values for the parameters.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
... I forgot one other comment:
When I attempt to enter the Custom Column with the code from the mrexcel.com link:
Source = Folder.Files("C:\Path")[Name]
The only "name" that appears in the list is the Property Name. There is no [Name] nor [FileName] that I am able to find.
Now, within my .csv files, there are columns that are titled "Name" and viewing the previous code, when PowerBI Promoted Headers it would then take "Name" from the .csv file, and now make it an actual Column Header. Perhaps that is breaking the link between [Name] as referencing the actual file name *.csv, and is now causing the issue?