cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
loekvs Occasional Visitor
Occasional Visitor

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

Accepted Solutions
Community Support Team
Community Support Team

Re: Folder Path to Column

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 other members find it more quickly.
1 REPLY 1
Community Support Team
Community Support Team

Re: Folder Path to Column

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 other members find it more quickly.

Helpful resources

Announcements
GregDeckler

How to Get Your Question Answered Quickly

Power BI Super User, Greg Deckler, explains

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Users Online
Currently online: 53 members 1,044 guests
Please welcome our newest community members: