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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Folder name to Column

I am trying to create a report where the excel sheets are all stored inside separate folders inside the root directory folder. If I use the root directory folder for "Get Data", is there a way to make the respective names of the separate folders the excel sheet was in as a column in Power BI?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

 

You can add a custom column with below formula to get file's parent folder name as custom column value.

#"Added Custom" = Table.AddColumn(#"Previous Steps", "Parent", each List.First(List.LastN(Text.Split([Folder Path],"\"),2)))

6.png

 

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous,


If you can please share some sample to test, it is hard to coding formula from simple description.

How to Get Your Question Answered Quickly

 

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

GL CODEDATECONSIGNMENT/REFERENCEORDER NUMBER  CHARGE    FUEL    SUBTOTAL    GST    TOTAL  
 3810 0000 1190 1000 18/06/2018P4419448.1O4419448 $  126.78  $  126.78 $    12.68 $  139.46

 

 

GL CODEDATECONSIGNMENT/REFERENCEORDER NUMBER CHARGE  FUEL  SUBTOTAL  GST  TOTAL 
4450 0735 6800 0000   $    78.60 $           -   $    78.60 $       7.86 $    86.46

 

 

Here is an example. These two tables are in separate excel files in excel (Let's call them A and B). A and B themselves are also in separate folders, where A is in Folder C and B is in Folder D. Folder C and D are both inside root folder E. I want to know if I run Power BI with folder E as the root folder, if it's posisble to create a column where if the file is from Folder C it will get "C" as a value in the column, or if it s from Folder it will get a "D" value in that column for multiple folders (20+)

 

Thank for your time.

Anonymous
Not applicable

Hi @Anonymous,

 

You can add a custom column with below formula to get file's parent folder name as custom column value.

#"Added Custom" = Table.AddColumn(#"Previous Steps", "Parent", each List.First(List.LastN(Text.Split([Folder Path],"\"),2)))

6.png

 

Regards,

Xiaoxin Sheng

itsmebvk
Continued Contributor
Continued Contributor
Anonymous
Not applicable

In this case the file names in this folders are random worksheets rather than 5 different CSVs. How does this change the steps I need to use?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors