Import Data from Folder with Power Query: Combine Multiple Files Instantly

Import data from folder with Power Query Excel tutorial showing file combination data transformation and automated reporting
Learn how to import and combine data from multiple files stored in a folder using Excel Power Query. This practical tutorial explains how to connect to a folder, combine files, transform imported data, handle consistent file structures, and refresh the query when new files are added. Ideal for Excel users, data analysts, accountants, finance professionals, and anyone who wants to automate repetitive data import and reporting tasks.

Every month it is the same chore. A new export lands in a folder, and you open it, copy the rows, and paste them under last month's. Do that twelve times a year, across several reports, and the hours add up. Worse, one slip corrupts the whole file. Power Query's From Folder feature ends the ritual. It reads every file in a folder and blends them into one table, ready to refresh.

This guide shows how to combine files the smart way. First, it explains the monthly-file problem. Then it covers From Folder, the sample file, and the helper function. Best practices and a full troubleshooting section follow. By the end, new files will fold in with a single click.

The Monthly-File Problem

Recurring exports arrive as separate files. Each month brings a fresh copy, same shape. Combining them by hand is slow and risky. So a repeatable method saves real time.

Manual combining does not scale. Twelve files a year soon becomes a burden. One copy-paste error can skew every total. So automation here pays off quickly.

What From Folder Does

From Folder points Power Query at a whole folder. It reads each file and stacks the rows. The result is one clean, combined table. Better still, new files join on refresh, as below.

From Folder blends every file into one refreshable table A folder Jan.csvFeb.csvMar.csv + drop Apr.csv later From FolderCombine & Transform One combined table every file, stacked

So you build the process once. After that, the folder does the work. Drop in next month's file, then refresh. As a result, the report updates itself.

How to Combine Files

The setup is quick and mostly guided. You point Excel at the folder. Then you choose Combine and Transform. Power Query does the stacking for you.

Combine a folder of files: 1. Go to Data > Get Data > From File > From Folder. 2. Browse to the folder, then click OK. 3. In the preview, click Combine & Transform Data. 4. Confirm the sample, then Close & Load. Excel appends every file into one table. So all your months arrive together.

The Sample File and Helper Function

Behind the scenes, Power Query is clever. It picks one file as a sample to shape. Then it turns your steps into a function. That function runs on every file, as below.

Behind the scenes: one transform, run on every file Sample fileyou shape this one Transform functionthe recorded recipe JanFebMarApr results appended into one table
Shape the sample, not each file. Any transform on the sample applies to all. So clean the sample once, and every file follows. That is the real power of the approach.

Keep the Source Filename

Combined rows can lose their origin. You may forget which file a row came from. A Source.Name column solves that neatly. It records the filename beside each row.

Track the file of origin: 1. After combining, look for the Source.Name column. 2. Keep it, since it names each row's file. 3. Optionally, extract the month from that name. For example, pull "Jan" out of "Jan.csv". So you can group and filter by month.

Add New Files, Just Refresh

This is the payoff of the whole setup. A new file needs no rebuild at all. You simply drop it into the folder. Then one refresh pulls it in, if you follow a few habits, as below.

A few habits keep folder imports trouble-free Same columnsevery file matches🗎Filter .csvskip stray files🏷Keep Source.Nameknow each fileHeaders oncepromote, not repeat
Keep imports smooth: - Make sure every file shares the same columns. - Filter the file list to one type, like .csv. - Keep Source.Name to trace each row. - Promote headers once, not on every file. Follow these, and refresh is all it takes. So the folder becomes a self-updating source.

Troubleshooting Folder Imports

All three problems below are the most common. Each has a clear cause and a quick fix.

The files have mismatched columns

Combining assumes every file shares a structure. So one odd file creates gaps or errors. First, open the offending file and compare its headers. Then fix the column names so they match the rest. If a file is truly different, move it out of the folder. You can also reorder columns by name in the sample transform. After that, the combine lines up cleanly.

The folder holds mixed file types

A folder often collects stray files over time. A rogue PDF or image will break the combine. First, do not combine straight from the raw list. Instead, filter the Extension column to your type. Keep only .csv or only .xlsx, for example. Then run Combine on that filtered list. So only the right files ever get processed.

Header rows appear as data

Sometimes each file's header repeats inside the data. This happens when headers are promoted at the wrong step. First, open the sample file transform. Then check where Promote Headers runs. It should run once, after the files combine. Remove any duplicate promote step inside the function. After that, the headers sit at the top only.

Frequently Asked Questions

  • How do I combine multiple files with Power Query?+
    Use Data, Get Data, From File, then From Folder. Point it at the folder and click Combine and Transform. Power Query stacks every file into one table. So all your files load together.
  • Do the files need the same columns?+
    Yes, the files should share the same structure. So each one needs matching column names. A different file creates gaps or errors. Therefore fix the headers or move odd files out.
  • How do I add a new file to the combined table?+
    Just drop the new file into the folder. Then click Refresh in Excel. Power Query reads it and stacks its rows. So no rebuild is ever needed.
  • How do I know which file each row came from?+
    Keep the Source.Name column after combining. It records the filename beside each row. You can even extract the month from it. So grouping by file becomes easy.