Power Query Problems

Keep SharePoint File Names When Combining Files in Excel Power Query

Ayan MasoodAyan Masood Dec 2, 2026 868 views

Question details

Keep the original SharePoint workbook name on every row when combining files in Power Query.

Keep SharePoint File Names When Combining Files in Excel Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
Combining workbooks from a SharePoint folder and retaining their names for traceability or date extraction.
Observed behavior
The original file name is missing from the combined rows.
Before you start

Confirm that you can access the SharePoint site and that the workbooks have a consistent structure. Identify the site URL and the folder path you want to filter in Power Query.

Solution 1Recommended

Preserve the file name before expanding combined data

Keep file metadata alongside each transformed table so the source name appears on every expanded row.

1
Connect to SharePoint

In Excel, select Data > Get Data > From Online Services > From SharePoint Folder. Enter the SharePoint site URL, sign in if prompted, and select Transform Data.

2
Filter the target folder

In Power Query Editor, use the Folder Path filter to select the folder containing the workbooks. Filter the Name or Extension column as needed to exclude unrelated files.

3
Create the file transformation

Use the Combine Files button in the Content column header and select the worksheet or table to import. The combine process creates a sample-file transformation and a function for applying it to the files.

4
Keep the source-name column

In the main query, review Applied Steps and find the step before the transformed tables are expanded. Keep the file Name column, or the Source.Name column if Power Query renamed it, and rename it SourceFile. Edit or remove a column-selection step if it removed the name.

5
Expand the transformed tables

Select the expand button in the transformed table column header and choose the data columns to import. Power Query repeats SourceFile for each expanded row from that file.

6
Load or extract the date

If the filename contains a date, select SourceFile and use Add Column > Extract to isolate the relevant text, then set an appropriate data type. Select Home > Close & Load when the result is ready.

Preserve the file name before expanding combined data
Check the generated steps: The combine wizard may already retain the filename as Source.Name. If it is missing, check the column-selection and rename steps before the table expansion; the filename must still be present at that point.
Free Microsoft Office alternative

Work with combined spreadsheet data in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface. Open compatible Excel files and work with combined data in WPS Spreadsheets for an easy transition from Microsoft Office. It does not fix Excel Power Query or replace the SharePoint combine workflow described above.

Review source filename columns in combined spreadsheet dataCompatible with Microsoft Excel XLSX and XLS filesFamiliar spreadsheet interface for an easier transitionFree and lightweight Office alternative
QA img-9

Frequently Asked Questions

Why did the file name disappear after I combined the files?

A generated or edited step may have removed the Name or Source.Name column. In Power Query Editor, check Applied Steps before the transformed table is expanded and keep that column in any column-selection step.

How can the filename appear on every imported row?

Keep the filename column alongside the transformed table column, then use the table column's expand button. Power Query repeats the filename for each row expanded from that file.

Can I extract a date from the SharePoint filename?

Yes. After retaining the filename as SourceFile, select it and use Add Column > Extract to isolate the date text. Set the resulting column to a date type if the text can be interpreted as a date.

Which SharePoint URL should I enter?

In Data > Get Data > From Online Services > From SharePoint Folder, enter the SharePoint site URL rather than an individual workbook URL. After connecting, filter Folder Path to the folder you need.