Power Query Problems

Add the Source File Name to Power Query Data in Excel

Nimra MalikNimra Malik Dec 2, 2026 868 views

Question details

The user wants to add the source file name to each row of data imported with Power Query.

Add the Source File Name to Power Query Data in Excel
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
Combining files from a folder or importing a single file while preserving its name for traceability.
Observed behavior
Each imported row should include the name of the file it came from.
Before you start

Confirm whether your query uses a folder connector or imports a single file. For a folder import, place the files to combine in the same folder and check that their data structures are compatible.

Solution 1Recommended

Retain file names when combining files from a folder

Use the folder listing's Name column to identify the source file for each combined row.

1
Connect to the folder

In Excel, select Data > Get Data > From File > From Folder, choose the folder, and select Transform Data.

2
Combine the files

In Power Query Editor, use the combine files button on the Content column and choose the table, sheet, or other data to import from the sample file.

3
Check the file name column

In the combined query, inspect Applied Steps and keep the Name column from the folder listing. It may be renamed Source.Name during the combine process. If a step removes it, edit that step to retain it.

4
Expand and load the data

If the transformed tables are not already expanded, select the expand icon on the transformed-table column. Keep the file name column alongside the expanded data, rename it Source File if desired, and select Home > Close & Load.

Retain file names when combining files from a folder
Check the resulting rows: Each expanded row should display the name of the file from which it was imported.
Free Microsoft Office alternative

Work with imported spreadsheet data in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for a smoother move between office suites. It does not fix or replace Excel Power Query's combine-files workflow.

Review source file labels alongside imported spreadsheet dataOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for everyday analysisWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Where does the file name come from in a folder query?

The From Folder connector lists files with a Name column. Keep that column in the combined query so it remains beside the expanded data.

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

An Applied Step may have removed the Name or Source.Name column. In Power Query Editor, inspect the steps and edit the step that removes columns so the file name is retained.

Can I rename Source.Name to something clearer?

Yes. In Power Query Editor, right-click the Source.Name column header, select Rename, and enter a name such as Source File.

Does a file name parameter update automatically when I change files?

Not if it is only a manually entered label. Use Home > Manage Parameters to update its value when the file changes, or use the parameter in the source setup to keep the reference and label aligned.