Forum Discussion

ryan1919's avatar
ryan1919
Frequent Visitor
3 years ago
Solved

Transform Sample File: Add Column>Custom Column to add "File Name"

PBIC,   I have a Power BI Desktop file, and the data is sourced from multiple .csv files within a single folder. Within Power Query, I am attempting to add a new custom column that would show the ...
  • v-jingzhang's avatar
    v-jingzhang
    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.