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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
sabd80
Helper III
Helper III

Power Query Add part of the file path to the data

Hi,

I am loading 12 files from SharePoint into Power BI, with each file representing a specific period or month. Since this information is not present within the files, I extract it from the file path. To incorporate this data, I have created a new column called "Period."


= Table.AddColumn(#"Filtered Rows", "Custom", each Text.Middle( [Folder Path], 123, 11))

 

 

I want to add the "Period" column to each data file to label each row with the corresponding period.

Can you help?

11 REPLIES 11
kushanNa
Responsive Resident
Responsive Resident

Hi,

When you say '12 files,' are these Excel files that you are trying to combine? And once you combine them, should each row have a period assigned to it? Something like that? Any sample data or screenshot you can provide to show what you're trying to do here?

Khushidesai0109
Continued Contributor
Continued Contributor

Hiii @sabd80 

Which part do you need to include in new column??

I need to include Periodic_01 from the folder path.

I already created the column Period which has that part from the path.

Try this

 

= Table.AddColumn(#"Filtered Rows", "Period", each Text.AfterDelimiter([Folder Path], "/", {0, RelativePosition.FromEnd}), type text)

it is returning blank

Can you share me the 1-2 path for me to understand and give you proper response

https://rsbsb.sht.com/sites/O365-SAPLInventoryModel/Shared Documents/General/01_Periodic_Loads/Current_Year/Actual/Periodic_01/

= Table.AddColumn(#"Filtered Rows", "Period", each Text.AfterDelimiter([Folder Path], "/Actual/"), type text)

try this please

@Khushidesai0109 , I know how to extract the part I want, what I need help with how to add this column to the data in each file.

Steps to Add "Period" to Each File's Data in Power BI

1. Ensure the "Period" Column Exists Before Expanding Files

You are currently working with metadata (file details) before expanding the contents. That’s the right place to extract Period, so ensure this step happens before combining the files.

2. Expand the Binary Contents (CSV or Excel Files)

  • Click the expand icon next to the Content/Binary column.
  • Select the relevant columns from the data inside the files.

    3. Add the "Period" Column to the Expanded Data

    Once expanded, the extracted "Period" column should still be present from the earlier step. However, if it's missing after expansion, follow these steps:

    • In Power Query, locate the step where you expand the data.
    • Ensure "Period" is retained after expansion.
    • If it disappears, merge back the "Period" column by using a common key (such as Name or Folder Path).

      4. Use Table.AddColumn to Append "Period" to Each Row

      If the "Period" column is lost after expansion, explicitly add it using:

       

      = Table.AddColumn(ExpandedTable, "Period", each LookupTable[Period]{List.PositionOf(LookupTable[Name], [Name])}, type text)
       

      (This ensures "Period" from metadata is applied to the expanded table.)

      5. Load the Final Table into Power BI

      • Ensure the final table includes all file data with the "Period" column.
      • Click Close & Apply to load it into Power BI.

I could not see the column Period after the expanssion, so I applied the code in point 4, but I get this error:

Expression.Error: The name 'LookupTable' wasn't recognized. Make sure it's spelled correctly.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors