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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Source.Name Column in Transform Sample File

Hi,

 

 

I have a table called "Cost Sheets". The first column by default is called "Source.Name" and contains the name of the Excel file that the data is taken from.

 

This column does not appear in the "Transform Sample File" table.

 

Is it possible to recreate this column in the "Transform Sample File" table? This would allow me to achieve the analysis I am looking for.

 

 

Many thanks, Adam

6 REPLIES 6
Syndicate_Admin
Administrator
Administrator

Hi @adam-starkie ,

When connecting to a folder to combine files, Transform Sample File table has been quoted the sample file name already in Power Query.

 

If not want to change these initial queries, the direct way to achieve it is to duplicate the Sample file query as a new query without the file name, then add a custom column like this in Transform Sample File

= Table.AddColumn(#"Promoted Headers", "File Name", each #"Sample File (2)"{0}[Name])

vyingjl_0-1635145502143.pngvyingjl_1-1635145520145.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Syndicate_Admin
Administrator
Administrator

Hi @adam-starkie ,

When connecting to a folder to combine files, Transform Sample File table has been quoted the sample file name already in Power Query.

 

If not want to change these initial queries, the direct way to achieve it is to duplicate the Sample file query as a new query without the file name, then add a custom column like this in Transform Sample File

= Table.AddColumn(#"Promoted Headers", "File Name", each #"Sample File (2)"{0}[Name])

vyingjl_0-1635145502143.pngvyingjl_1-1635145520145.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

v-yingjl
Community Support
Community Support

Hi @Anonymous ,

When connecting to a folder to combine files, Transform Sample File table has been quoted the sample file name already in Power Query.

 

If not want to change these initial queries, the direct way to achieve it is to duplicate the Sample file query as a new query without the file name, then add a custom column like this in Transform Sample File

= Table.AddColumn(#"Promoted Headers", "File Name", each #"Sample File (2)"{0}[Name])

vyingjl_0-1635145502143.pngvyingjl_1-1635145520145.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

watkinnc
Super User
Super User

So if you are using a transform file, I would assume that you have the source as a folder. Can't you just keep the Column with the name of the file, rename it Source.Name, and then after applying the transforms in the sample file, expanding the tables?

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Anonymous
Not applicable

Hi Nate,

 

 

Thank you for the response. Yes, the source is a folder and the files within that folder have identical structure. Key information is stored in the filenames of the individual files.

 

When I combine and transform the files from the folder, I can see that there is a column called Source.Name containing the filenames by default - however when I go into the 'Transform Sample File' tab to apply my transformations, there is no filename column. 

 

How do I recreate this column? I feel like I'm missing something really obvious here.

 

 

Thansk, Adam

Ehren
Employee
Employee

As you've observed, by default the "Transform Sample File" query doesn't have access to the file name. One way to change this would be to add a file-level query parameter called FileName and reference this in "Transform Sample File". This will add a FileName parameter to the function that's auto-generated from "Transform Sample File". Then you just need to update the place where the generated function is called to pass in the actual file name as well as the other info.

 

Another option would be to utilize the file name after the custom function is called. But perhaps that's too late for what you're trying to do.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors