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
loekvs
New Member

Folder Path to Column

Hello forum members,

 

Can someone explain me how te add a column with the folder names to my PowerBI table?

2019-07-09_14-37-10.png
Thanx in advance,

Loek

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @loekvs ,

 

We can edit the steps after Rename column name as below. M code for your reference as well.

 

let
    Source = Folder.Files("D:\Case\New folder"),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Filtered Hidden Files2" = Table.SelectRows(#"Renamed Columns1", each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function2" = Table.AddColumn(#"Filtered Hidden Files2", "Transform File (2)", each #"Transform File (2)"([Content])),
    #"Expanded Transform File" = Table.ExpandTableColumn(#"Invoke Custom Function2", "Transform File", {"Date", "cat", "Sales"}, {"Transform File.Date", "Transform File.cat", "Transform File.Sales"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Transform File",{"Folder Path", "Transform File.Date", "Transform File.cat", "Transform File.Sales"})
in
    #"Removed Other Columns"

folder.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @loekvs ,

 

We can edit the steps after Rename column name as below. M code for your reference as well.

 

let
    Source = Folder.Files("D:\Case\New folder"),
    #"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
    #"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
    #"Filtered Hidden Files2" = Table.SelectRows(#"Renamed Columns1", each [Attributes]?[Hidden]? <> true),
    #"Invoke Custom Function2" = Table.AddColumn(#"Filtered Hidden Files2", "Transform File (2)", each #"Transform File (2)"([Content])),
    #"Expanded Transform File" = Table.ExpandTableColumn(#"Invoke Custom Function2", "Transform File", {"Date", "cat", "Sales"}, {"Transform File.Date", "Transform File.cat", "Transform File.Sales"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Transform File",{"Folder Path", "Transform File.Date", "Transform File.cat", "Transform File.Sales"})
in
    #"Removed Other Columns"

folder.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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.