Skip to main content
Microsoft
Support
Support
Sign in
Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.
Excel for Microsoft 365 Excel 2024 Excel 2021 Excel 2019 Excel 2016 More...Less
Use Power Query to combine multiple files with the same schema stored in a single folder into one table. For example, each month you want to combine budget workbooks from multiple departments, where the columns are the same, but the number of rows and values differ in each workbook. Once you set it up, you can apply additional transformations as you would with any single imported data source andthen refresh the data to see results for each month.
Note This topic shows how to combine files from a folder. You can also combine files stored in SharePoint, Azure Blob Storage, and Azure Data Lake Storage. The process is similar.
Keep it simple:
-
Ensure that all the files you want to combine are contained in a dedicated folder without extraneous files. Otherwise, all files in the folder and any subfolders you select are included in the data to be combined.
-
Each file should have the same schema with consistent column headers, data types, and number of columns. The columns do not have to be in the same order as the matching is done by column names.
-
If possible, avoid unrelated data objects for data sources that can have more than one data object, such as a JSON file, an Excel workbook, or Access database.
Each of these files followa simple pattern, only one table of data in each file.
-
SelectData> Get Data > From File > From Folder. The Browse dialog box appears.
-
Locate the folder containing the files you want to combine.
-
A list of the files in the folder appears in the <Folder path> dialog box.Verify that all the files you want are listed.
-
Select one of the commands at the bottom of the dialog box, for exampleCombine > Combine & Load. There are additional commands discussed in the section About all those commands.
-
If you select any Combine command, The Combine Files dialog box appears. To change file settings, select each file from the Sample File box, set the File Origin, Delimiter, and Data Type Detection as desired. You can also select or clear the Skip files with errors checkbox at the bottom of the dialog box.
-
Select OK.
Result
Power Query automatically creates queriesto consolidate the data from each file into a worksheet. The query steps and columns created depend on which command you choose. For more information, see the section, About all those queries.
-
SelectData> Get Data > From File > From Folder. The Browsedialog box appears.
-
Locate the folder containing the files you want to combine.
-
A list of the files in the folder appears in the <Folder path> dialog box.Verify that all the files you want are listed.
-
Select one of the commands at the bottom of the dialog box, for exampleCombine > Combine & Transform. There are additional commands discussed in the section About all those commands.
The Power Query Editor appears.
-
The Value column is a structured List column. Select the Expand
icon, and then select Expand to New rows.
-
The Valuecolumn is now a structured Record column.Select the Expand
icon. A drop-down dialog box appears.
-
Keep all the columns selected. You may want to clear the Use original column name as a prefix check box. Select OK.
-
Select all the columns that contain data values.Select Home, the arrow next to Remove Columns, and then select Remove Other Columns.
-
Select Home > Close & Load.
Result
Power Query automatically creates queriesto consolidate the data from each file into a worksheet. The query steps and columns created depend on which command you choose.For more information, see the section, About all those queries.
Each of these data sources can have more than one object to import. An Excel workbook can have multiple worksheets, Excel tables, or named ranges. An Access database can have multiple tables and queries.
-
SelectData> Get Data > From File > From Folder. The Browsedialog box appears.
-
Locate the folder containing the files you want to combine.
-
A list of the files in the folder appears in the <Folder path> dialog box.Verify that all the files you want are listed.
-
Select one of the commands at the bottom of the dialog box, for exampleCombine > Combine & Load. There are additional commands discussed in the section About all those commands.
-
In the Combine Files dialog box:
-
In the Sample File box, select a file to use as sample data used to create the queries. You can either not select an object or select just one object. But,you can't select more than one.
-
If you have many objects, use the Search box to locate an object or the Display Options along with the Refresh button to filter the list.
-
Select or clear the Skip files with errors checkbox at the bottom of the dialog box.
-
-
Select OK.
Result
Power Query automatically creates a query to consolidate the data from each file into a worksheet. The query steps and columns created depend on which command you choose.For more information, see the section, About all those queries.
For more flexibility, you can explicitly combine files in the Power Query Editor by using the Combine Files command. Let’s say the source folder has a mixture of file types and subfolders, and you want to target specific files with the same file type and schema but not others. This can improve performance and help simplify your transformations.
-
Select Data > Get Data > From File > From Folder. The Browse dialog box appears.
-
Locate the folder containing the files you want to combine, and then select Open.
-
A list of all the files in the folder and subfolders appears in the <Folder path> dialog box. Verify that all the files you want are listed.
-
Select Transform Data at the bottom. The Power Query Editor opens and displays all the files in the folder and any subfolders.
-
To select the files you want, filter columns, such as Extension or Folder Path.
-
To combine the files into single table, select the Content column that contains each Binary (usually the first column), and then select Home > Combine Files. The Combine Files dialog box appears.
-
Power Query analyzes an example file, by default the first file in the list, to use the correct connector and identify matching columns.
To use a different file for the example file, select it from the Sample File drop-down list.
-
Optionally, at the bottom, select Skip files with errors to exclude those files from the result.
-
Select OK.
Result
Power Query automatically creates a queriesto consolidate the data from each file into a worksheet. The query steps and columns created depend on which command you choose.For more information, see the section, About all those queries.
There are several commands you can select and each one has a different purpose.
-
Combine and Transform Data To combine all the files with a query, and then launch the Power Query Editor, select Combine > Combine and Transform Data.
-
Combine and LoadTo display the Sample file dialog box, create a query, and then load to worksheet, select Combine > Combine and Load.
-
Combine andLoad ToTo display the Sample file dialog box, create a query, and then display Import dialog box, select Combine > Combine and Load To.
-
Load To create a query with one step, and then load to a worksheet, select Load > Load.
-
Load ToTo create a query with one step, and then display the Import dialog box, select Load > Load To.
-
Transform DataTo create a query with one step, and then launch the Power Query Editor, select Transform Data.
However you combine files, several supporting queries are created in the Queries pane under the "Helper Queries" group.
-
Power Query creates a"Sample File" query based on the example query.
-
A "Transform File"function query uses the "Parameter1" query to specify each file (or binary) as input to the "Sample File"query. This query also creates the Content column containing the file contents and automatically expands the structured Record column to add the column data to the results.The "Transform File"and "Sample File" queriesare linked, so that changes to the "Sample File"query are reflected in the "Transform File" query.
-
The query containing the final results is in the "Other queries"group. By default, it is named after the folder you imported the files from.
For further investigation, right click each query and select Edit to examine each query step and to see how the queries work in concert.
See Also
Power Query for Excel Help
Append queries
Combine files overview (docs.com)
Combine CSV files in Power Query (docs.com)
Need more help?
Want more options?
Discover Community
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Microsoft 365 subscription benefits
Microsoft 365 training
Microsoft security
Accessibility center
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
Thank you for your feedback!
×