Import data from a folder with multiple files (Power Query) (2024)

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.

Import data from a folder with multiple files (Power Query) (2)

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:

Each of these files followa simple pattern, only one table of data in each file.

  1. SelectData> Get Data > From File > From Folder. The Browse dialog box appears.

  2. Locate the folder containing the files you want to combine.

  3. A list of the files in the folder appears in the <Folder path> dialog box.Verify that all the files you want are listed.

    Import data from a folder with multiple files (Power Query) (3)
  4. 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.

  5. 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.

  6. 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.

  1. SelectData> Get Data > From File > From Folder. The Browsedialog box appears.

  2. Locate the folder containing the files you want to combine.

  3. A list of the files in the folder appears in the <Folder path> dialog box.Verify that all the files you want are listed.

  4. 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.

  5. The Value column is a structured List column. Select the Expand

    Import data from a folder with multiple files (Power Query) (4)

    icon, and then select Expand to New rows.

    Import data from a folder with multiple files (Power Query) (5)
  6. The Valuecolumn is now a structured Record column.Select the Expand

    Import data from a folder with multiple files (Power Query) (6)

    icon. A drop-down dialog box appears.

    Import data from a folder with multiple files (Power Query) (7)
  7. Keep all the columns selected. You may want to clear the Use original column name as a prefix check box. Select OK.

  8. Select all the columns that contain data values.Select Home, the arrow next to Remove Columns, and then select Remove Other Columns.

  9. 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.

  1. SelectData> Get Data > From File > From Folder. The Browsedialog box appears.

  2. Locate the folder containing the files you want to combine.

  3. A list of the files in the folder appears in the <Folder path> dialog box.Verify that all the files you want are listed.

  4. 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.

  5. 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.

  6. 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.

  1. Select Data > Get Data > From File > From Folder. The Browse dialog box appears.

  2. Locate the folder containing the files you want to combine, and then select Open.

  3. 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.

  4. Select Transform Data at the bottom. The Power Query Editor opens and displays all the files in the folder and any subfolders.

  5. To select the files you want, filter columns, such as Extension or Folder Path.

  6. 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.

  7. 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.

  8. Optionally, at the bottom, select Skip files with errors to exclude those files from the result.

  9. 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.

Import data from a folder with multiple files (Power Query) (8)

  • 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.

Import data from a folder with multiple files (Power Query) (9)

Microsoft 365 subscription benefits

Import data from a folder with multiple files (Power Query) (10)

Microsoft 365 training

Import data from a folder with multiple files (Power Query) (11)

Microsoft security

Import data from a folder with multiple files (Power Query) (12)

Accessibility center

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Import data from a folder with multiple files (Power Query) (13)

Ask the Microsoft Community

Import data from a folder with multiple files (Power Query) (14)

Microsoft Tech Community

Thank you for your feedback!

×

Import data from a folder with multiple files (Power Query) (2024)
Top Articles
Latest Posts
Recommended Articles
Article information

Author: Kelle Weber

Last Updated:

Views: 5501

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Kelle Weber

Birthday: 2000-08-05

Address: 6796 Juan Square, Markfort, MN 58988

Phone: +8215934114615

Job: Hospitality Director

Hobby: tabletop games, Foreign language learning, Leather crafting, Horseback riding, Swimming, Knapping, Handball

Introduction: My name is Kelle Weber, I am a magnificent, enchanting, fair, joyous, light, determined, joyous person who loves writing and wants to share my knowledge and understanding with you.