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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.