How to merge files and tables in Excel using Power Query

Configurare noua (How To)

Situatie

If you spend Mondays copying data from email attachments into a “Master” sheet, you’re not working in Excel—you’re doing manual labor. Power Query fixes that. Master these three core data consolidation workflows to turn hours of copy-pasting into a single Refresh click.

Solutie

The case for appending, merging, and consolidating data

Stop the copy-paste madness once and for all

Cleaning data is a classic Power Query use case, but the real power comes when you stop thinking about individual tables and start thinking at the system level. Most Excel users spend a huge chunk of their week copy-pasting data or chasing down the latest CSV.

Power Query helps eliminate this manual labor through three consolidation workflows:

  1. Appending tables: This is a vertical stack. You use this when you have multiple tables with the same headers—like monthly scores—and want to pile them into one long master list.
  2. Relational merging: This is a horizontal join. You use this to pull related information from one table into another based on a shared data point, such as a person’s name.
  3. Folder consolidation: This is the ultimate automation tool. You point Excel at a folder on your drive, and it automatically grabs all the files inside, cleans them, and stacks them into a single table.

By mastering these, you turn Excel from a static calculator into a dynamic data hub.

Workflow 1: Appending tables from a single workbook

Stacking multiple sheets into one master list

Power Query’s Append feature lets you unify several local tables into a single continuous dataset.

The scenario: You have a workbook with 12 separate tabs—one for each month of the year—and you need to combine them to create an annual summary report.

Before you start, ensure your workbook is prepared:

  1. Create a blank worksheet (such as one called Summary) for the output.
  2. Format each range as an Excel Table (Ctrl+T).
  3. Name each table (JanSales, FebSales, and so on).
  4. Ensure headers match across tables.

A blank Summary worksheet in an Excel workbook that also contains monthly worksheet tabs.

The Jan worksheet in an Excel workbook containing monthly worksheets and a summary page, with the Jan table named JanSales.

The Feb worksheet in an Excel workbook containing monthly worksheets and a summary page, with the Feb table named FebSales.

Once you’ve checked your setup, use this method to stack them:

  1. Open the Data tab and click Get Data.
  2. Hover over From Other Sources and click Blank Query.
  3. In the Power Query Editor formula bar, type = Excel.CurrentWorkbook() and press Enter. This loads all tables and named ranges.
  4. Click the filter arrow on the Name column, then select Text Filters > Ends With.
  5. Type Sales into the first value field, then click OK. This filters only your Sales tables.
  6. Click the Expand icon (two arrows) in the Content column, uncheck Use original column name as prefix, and click OK.

The Get Data button in the Data tab of a blank worksheet in Microsoft Excel.

Blank Query is selected from the Get Data options in Microsoft Excel.

=Excel.CurrentWorkbook() is typed into the formula bar in the Power Query Editor, and a list of all tables and named ranges appears below.

Ends With is selected from the Text Filters options in a Power Query column's filter options.

Ends with and Sales are selected in the Filter Rows dialog in the Power Query Editor.

The Expand icon is selected in a column in Power Query Editor, and Use original column name as prefix is unchecked.

Now that all the data is visible, you’re ready to set the data types and load the results:

  1. Click the ABC123 icon in the Date header and select Date.
  2. Click the bottom half of the split Close & Load button and click Close & Load To.
  3. Select Table and Existing Worksheet, then click cell A1 on your blank Summary sheet and click OK.
  4. Format the Amount column as Accounting using the drop-down menu in the Home tab.

Date is selected in a column's number format options in the Power Query Editor.

Close and Load To... is selected in the Close and Load drop-down menu in Microsoft Excel's Power Query Editor.

Table and Existing Worksheet are selected in the Import Data dialog in Excel, and cell A1 of a Summary worksheet is nominated as the destination.

An Amount column in a Power Query output table is assigned the Accounting number format.

You now have a single, unified master table on your Summary sheet.

A Power Query Append output table with dates in column B, categories in column B, items in column C, and amounts in column D.

The best part? It’s hands-off. Add a new table, then click Refresh All in the Data tab, and it’s included automatically.

Refresh All is selected in the Data tab of Microsoft Excel's ribbon.

Workflow 2: Connecting tables using a common column

Relational merging in Power Query allows you to pull specific data points from one table into another by finding a common link.

The scenario: You have one table (AgeData) containing employee names, ages, and locations, and another table (DeptData) containing those same names paired with their department and job level. These tables are on separate worksheets in the same workbook, and you want to combine them into one.

Two tables, each on separate Excel worksheet tabs, containing details about the same employees.

First, you need to load both tables into Power Query by creating Connections:

  1. Select a cell in your first table (AgeData) and click Data > From Table/Range.
  2. In the Power Query Editor, click the bottom half of the split Close & Load button and click Close & Load To.
  3. Check Only Create Connection and click OK.
  4. Repeat these steps for your second table (DeptData), then click Queries & Connections in the Data tab to see both these connections in the pane on the right.

A cell in an AgeData table in Excel is selected, and From Table or Range is highlighted in the Data tab.

An AgeData query is loaded into Power Query Editor, and Close and Load To is selected in the Close and Load drop-down menu.

Only Create Connection is selected in Microsoft Excel's Import Data dialog box.

The Queries and Connections pane in Excel shows AgeData and DeptData queries loaded as connections only.

Now that both tables are loaded, you’re ready to perform the merge:

  1. In the Data tab, click Get Data > Combine Queries > Merge.
  2. In the Merge dialog, select one table in the top drop-down and the other in the bottom drop-down.
  3. Click the matching bridge column (in this case, Employee Name) in both table previews to highlight them.
  4. Ensure the Join Kind is set to Left Outer, then click OK. This keeps all rows from the first table and adds matching data from the second.

At this point, the Power Query Editor opens. You’ll see all the columns from your first table displayed normally, but the data from the second table is condensed into a single new column where every cell simply says “Table”.

Merge is selected from the Combine Queries menu of the Get Data drop-down in Excel.

In the Merge dialog in Excel, AgeData is selected as the first table, and DeptData is selected as the second table.

The Employee Name columns in two tables are selected in Excel's Merge dialog.

Left Outer is selected as the Join Kind in Excel's Merge dialog.

A Merge query in Power Query Editor, with the data from an AgeData table displayed fully, and the DeptData table condensed into a single column.

Now that you can see the condensed data, you’re ready to unpack it:

  1. Click the Expand icon in the header of the new Table column.
  2. Uncheck any duplicated columns (such as Employee Name), and uncheck Use original column name as prefix to keep your column headers clean. Then, click OK.
  3. Finally, click the top half of the split Close & Load button to drop the merged results into a new worksheet.

The Expand column button in a condensed DeptData column in Power Query Editor.

Employee Name and Use original column name are unchecked in the Expand drop-down in Excel's Power Query Editor.

The top half of the split Close and Load button in the Power Query Editor is clicked to load Merge1 to a new Excel worksheet.

You’ve now successfully joined two separate lists without writing a single formula.

The output of two tables being merged in Excel's Power Query.

Because this is a dynamic connection, you don’t need to manually repeat the merge process. As always, if the source data changes, simply click Data > Refresh All (provided the source tables and column structure haven’t changed).

Workflow 3: Merging multiple files from a folder

Consolidating external documents automatically

The From Folder connector pulls data from every file in a directory. It’s ideal for recurring reports like weekly exports or monthly statements.

The scenario: Your coworkers drop weekly Excel files into a shared folder. Every workbook contains a worksheet tab named SalesData, and you need to combine them all into one summary sheet every Monday.

A Windows Explorer folder named Weekly Reports, with two Excel files named Sales_Week_[number].

An Excel file named Sales_Week_1, with a tab named SalesData containing a table of data.

An Excel file named Sales_Week_2, with a tab named SalesData containing a table of data.

Before connecting, ensure your incoming files and folders are standardized:

  1. Each file must contain a worksheet with the same name (for example, SalesData).
  2. Column headers should be consistent for clean consolidation.
  3. All files must be saved in the same dedicated folder.

Now, you need to point Excel to your data source, using the Power Query Editor as a security gate to make sure only the correct files get through:

  1. In the Data tab of a new Excel workbook, click Get Data > From File > From Folder.
  2. Browse to the folder containing the reports, then click Open.
  3. In the preview window, click Transform Data. You might be tempted to click Combine straightaway, but clicking Transform Data gives you the chance to make sure your report grabs only the files you need.
  4. You’ll now see a list of every file in the folder. Click the filter arrows in the Extension or Name columns to uncheck anything that isn’t part of the dataset.

From Folder is selected from the From File section of the Get Data drop-down menu in Excel.

A folder named Weekly Reports is selected in Windows File Explorer.

Transform Data is selected in the From Folder dialog in Excel.

The filter icon in the Name column of a Weekly Reports query in Power Query Editor is clicked.

Now you can tell Power Query how to open and stack those files:

  1. Click the Combine Files button in the header of the Content column.
  2. In the Combine Files dialog, select the SalesData worksheet from the list. This tells Power Query to extract that specific worksheet from each file. Click OK.
  3. In the Queries pane, select Transform Sample File. Any cleaning you do here—such as applying the correct formats to the Date and Amount columns—is applied to every file in the folder.
  4. Click back on the main query at the bottom of the list (usually named after your folder) to see the final stacked result. If needed, you can remove the Source column, but I prefer to keep it visible so I can see where each row came from.
  5. Click Close & Load to load the final table into your workbook.

The Combine Files icon in the header of a Content column in the Power Query Editor.

The SalesData worksheet tab is selected in Excel's Combine Files dialog.

Transform Sample File is selected in the Queries Pane in the Power Query Editor.

A query named Weekly Reports is selected in the Queries Pane of the Power Query Editor.

Close and Load is selected in the Home tab of the Power Query Editor to send a merged report back to a new worksheet.

You’ve now built an automated data pipeline.

The output of a query in Power Query that combines data from two files.

Next week, instead of opening a new file to copy-paste, just save it into that folder and click Data > Refresh All.

Tip solutie

Permanent

Voteaza

(0 din 0 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?