Building a Self-Updating Report from a Folder of Files with Power Query

In this tutorial, we'll show the steps of building a self-updating report from a folder of files with Power Query. Let’s explore how files are combined, cleaned, and loaded into a single refreshable report.

Building a Self-Updating Report from a Folder of Files with Power Query

Imagine receiving a new sales workbook every month and having to copy its data into a master report, adjust formulas, and update the monthly summary. The process is repetitive, time-consuming, and prone to errors. With Power Query, you can connect Excel to an entire folder rather than individual files. Once the connection and transformation steps are configured, you simply need to add new files to the folder and refresh the report.

In this tutorial, we’ll show the steps of building a self-updating report from a folder of files with Power Query. Let’s explore how files are combined, cleaned, and loaded into a single refreshable report.

Step 1: Connect Power Query to the Folder

Let’s consider a business that receives monthly sales records in separate Excel workbooks. Each workbook contains transaction dates, regions, salespersons, sales amounts, and other order details.

Connect to a Local Folder

  • Go to the Data tab >> select Get Data >> select From File >> select From Folder

1. Building a Self Updating Report from a Folder of Files with Power Query

  • Browse to the Monthly Sales folder or enter its path >> click Open
  • Select the files you want to combine
  • Click Transform Data instead of combining the files immediately
  • Power Query will display a table containing the files and their associated metadata

2. Building a Self Updating Report from a Folder of Files with Power Query

Connect to a SharePoint Folder

If your organization stores monthly files in SharePoint, you don’t need to download them individually.

  • Go to the Data tab >> select Get Data >> select From File >> select From SharePoint Folder

23. Building a Self Updating Report from a Folder of Files with Power Query

  • Enter the SharePoint site URL, for example: https://company.sharepoint.com/sites/Sales

24. Building a Self Updating Report from a Folder of Files with Power Query

  • Sign in using your organizational account
  • Select Transform Data
  • Filter the Folder Path column to the monthly sales folder and apply the same filename and extension filters

The remaining transformation process is essentially the same for local and SharePoint folders.

Step 2: Filter and Combine All Monthly Files

Before combining the files, filter the folder contents to prevent unrelated files from entering the report. Power Query will display a list of files along with their binary contents and metadata.

Filter Unnecessary Files:

  • Filter the Extension column to include only .xlsx
  • Click the filter drop-down in the Name column >> select Text Filters >> select Begins With >> enter Sales_
  • Filter the Folder Path column to exclude unwanted subfolders, if necessary

3. Building a Self Updating Report from a Folder of Files with Power Query

These filters exclude unrelated documents, temporary Excel files, and files from unwanted subfolders. They also allow future monthly workbooks to be included without manually selecting their filenames.

Combine Files:

  • Click the Combine Files icon in the header of the Content column
  • Select Sales_January.xlsx as the sample file
  • Select SalesTable from the available objects
  • Check Skip files with errors
  • Click OK

4. Building a Self Updating Report from a Folder of Files with Power Query

Power Query creates several helper queries, including Transform Sample File and Transform File. These queries define how each individual workbook is processed before its contents are appended to the combined table. Power Query applies a reusable transformation to every file and combines the results.

Keep the Source.Name column. It helps identify which workbook a particular record came from when investigating data quality issues.

6. Building a Self Updating Report from a Folder of Files with Power Query

Step 3: Handle Schema Drift in Monthly Files

In real-world reporting, source files do not always maintain the same structure. Someone might rename a column, remove an optional field, or introduce a new column. These structural changes are known as schema drift.

Instead of fixing these issues every month, define the expected structure in the Transform Sample File query.

In the Power Query Editor:

  • Select the Transform Sample File query
  • Go to the Home tab >> select Advanced Editor
  • Replace the existing code with the following Power Query M code:
let
    Source = Excel.Workbook(Parameter1, null, true),
    Data = Source{[Item="SalesTable", Kind="Table"]}[Data],

    // Handle renamed columns
    Renamed = if Table.HasColumns(Data, "Revenue")
        then Data
        else Table.RenameColumns(
            Data,
            {{"Sales Amount", "Revenue"}},
            MissingField.Ignore
        ),

    // Validate required columns
    Validated = if Table.HasColumns(
        Renamed,
        {
            "Date", "Order ID", "Region", "Product",
            "Units Sold", "Unit Price", "Revenue",
            "Cost", "Profit"
        }
    )
        then Renamed
        else error "Required columns are missing",

    // Standardize the column structure
    Standardized = Table.SelectColumns(
        Validated,
        {
            "Date", "Order ID", "Region", "Product",
            "Salesperson", "Units Sold", "Unit Price",
            "Revenue", "Cost", "Profit"
        },
        MissingField.UseNull
    ),

    // Assign consistent data types
    Typed = Table.TransformColumnTypes(
        Standardized,
        {
            {"Date", type date},
            {"Order ID", type text},
            {"Region", type text},
            {"Product", type text},
            {"Salesperson", type text},
            {"Units Sold", Int64.Type},
            {"Unit Price", type number},
            {"Revenue", type number},
            {"Cost", type number},
            {"Profit", type number}
        }
    ),

    // Reject files containing data errors
    Result = if Table.IsEmpty(
        Table.SelectRowsWithErrors(Typed)
    )
        then Typed
        else error "Invalid data in source file"
in
    Result
  • Click Done

7. Building a Self Updating Report from a Folder of Files with Power Query

Since these transformations are defined in the Transform Sample File query, Power Query applies them to every monthly workbook.

8. Building a Self Updating Report from a Folder of Files with Power Query

Return to the main query to verify the combined dataset.

9. Building a Self Updating Report from a Folder of Files with Power Query

How Schema Drift Is Handled:

Changes in future files Power Query action
Revenue renamed to Sales Amount Renames it back to Revenue
Salesperson column missing Creates the column with null values
Additional Notes column Removes the column
Column order changed Restores the original column order
Revenue or another required column missing Rejects the file
Revenue contains nonnumeric text Rejects the file
SalesTable is missing Rejects the file

Note: Power Query normally generates a parameter named Parameter1. If your generated parameter has a different name, use that name in the code.

Step 4: Handle and Track Bad Files

Selecting Skip files with errors prevents many file-level errors from interrupting the entire consolidation process. However, silently skipping a monthly sales file could result in an incomplete report. A better approach is to maintain a separate list of rejected files.

To create an error log:

  • Right-click the main Monthly Sales query >> select Duplicate

10. Building a Self Updating Report from a Folder of Files with Power Query

  • Rename the duplicated query to “Rejected Files”
  • In Applied Steps, remove all steps after Invoked Custom Function
  • Select the Transform File column
  • Go to the Home tab >> select Keep Rows >> select Keep Errors

11. Building a Self Updating Report from a Folder of Files with Power Query

  • Keep the Name column and remove the remaining columns
  • Load the query into a separate worksheet
  • Also verify that the main query removes errors from the invoked function column before expanding the combined data

To test how Power Query handles such situations, let’s introduce a new monthly file named Sales_April_2026.xlsx.

  • Delete the Revenue column from the April dataset without replacing it with Sales Amount
  • In the Power Query Editor, go to the Home tab >> select Refresh Preview >> select Refresh All

12. Building a Self Updating Report from a Folder of Files with Power Query

The transformation function will detect the missing required column and return an error for the April file. The following table summarizes how the workflow handles common problems.

File problem Action
Unrelated file format Excluded by folder filters
Temporary Excel file Excluded by filename filter
Revenue column renamed to Sales Amount Renamed back to Revenue
Missing Salesperson column Filled with null values
Additional Notes column Removed
Missing required column Rejected and logged
Invalid data type Rejected and logged
Unreadable workbook or missing SalesTable Rejected and logged

This approach allows valid files to continue feeding the report while making rejected files visible for investigation.

Important: Skipping a file does not correct its data. Review the error log before distributing the report.

Step 5: Add a Month Column and Load the Combined Data

Now that the data is combined and standardized, add a Month column so the report can summarize revenue by month.

  • Select the Date column
  • Go to the Add Column tab >> select Date >> select Month >> select Start of Month

13. Building a Self Updating Report from a Folder of Files with Power Query

  • Rename the new column to “Month”
  • Ensure its data type is Date
  • Rename the main query to “SalesData”
  • Go to the Home tab >> select Close & Load

14. Building a Self Updating Report from a Folder of Files with Power Query

Excel will load the combined data into a worksheet table. The table contains all records from the four monthly files.

15. Building a Self Updating Report from a Folder of Files with Power Query

Step 6: Build the Self-Updating Sales Report

Now that the consolidation process is ready, let’s create the self-updating sales report.

Create a Dynamic Monthly Summary

  • Create a new worksheet named Report and enter the following headers:
    • Month, Total Sales
  • In cell A2, enter the following formula to extract the unique months in chronological order:
=SORT(UNIQUE(SalesData[Month]))
  • Format the resulting dates using the custom number format mmm yyyy

16. Building a Self Updating Report from a Folder of Files with Power Query

  • In cell B2, enter the following formula to calculate total sales for each month:
=SUMIF(SalesData[Month],A2#,SalesData[Revenue])

The spill reference A2# ensures that the formula automatically calculates sales for every month returned by the first formula.

  • You can also calculate overall sales using:
=SUM(SalesData[Revenue])

17. Building a Self Updating Report from a Folder of Files with Power Query

Add a PivotTable:

Alternatively, you can create a PivotTable from the SalesData table. If you use a PivotTable, ensure that it refreshes after the underlying query finishes.

Now, let’s create a PivotTable from the combined data.

  • Select any cell within the SalesData table
  • Go to the Insert tab >> select PivotTable
  • Select New Worksheet
  • Arrange the PivotTable fields as follows:
    • Drag Date to the Rows field
    • Drag Region to the Columns field
    • Drag Revenue to the Values field

18. Building a Self Updating Report from a Folder of Files with Power Query

Add a PivotChart:

  • Select the PivotTable
  • Go to the PivotTable Analyze tab >> select PivotChart >> select a Clustered Column chart
  • Add the chart title “Monthly Sales by Region”

19. Building a Self Updating Report from a Folder of Files with Power Query

Step 7: Test the Report with a New Monthly File

Let’s check whether the report can handle new files and structural changes without modifying the query.

  • Create a new monthly sales workbook for May, with a filename that begins with Sales_
  • Convert the dataset into an Excel Table named SalesTable
  • Save the workbook in the Monthly Sales folder

20. Building a Self Updating Report from a Folder of Files with Power Query

  • Return to the Sales Report workbook
  • Go to the Data tab >> select Refresh All or press Ctrl + Alt + F5

21. Building a Self Updating Report from a Folder of Files with Power Query

Power Query will read the new workbook, rename Sales Amount to Revenue, add the missing Salesperson column, remove the Notes column, and append the records to the existing dataset.

  • Go to the PivotTable Analyze tab >> select Auto Refresh

22. Building a Self Updating Report from a Folder of Files with Power Query

No additional formulas, manual copying, or changes to the query are required. All formulas and PivotTables are updated with one click.

Step 8: Automatically Refresh the Report When Opening Excel

You can also configure Excel to refresh the report whenever you open the workbook.

  • Go to the Data tab >> select Queries & Connections
  • Right-click the SalesData query >> select Properties

25. Building a Self Updating Report from a Folder of Files with Power Query

  • Select Refresh every: 60 minutes
  • Select Refresh data when opening the file
  • Click OK

26. Building a Self Updating Report from a Folder of Files with Power Query

Note: Keep in mind that Power Query does not continuously monitor a folder for new files. It discovers new files when a refresh is triggered, and standard Excel desktop refresh settings do not automatically update a closed workbook.

Best Practices for Folder-Based Power Query Reports

Best practice Why it matters
Use consistent table and file names Makes file identification reliable.
Keep the report outside the source folder Prevents accidental self-import.
Retain source filenames Improves data traceability.
Validate required columns Prevents structurally incomplete data from entering the report.
Maintain a rejected-file log Avoids unnoticed data loss.
Avoid keeping duplicate versions of monthly files Prevents double-counting transactions.
Keep the designated sample file valid and available Protects the generated combine-file workflow.
Review missing values and monthly totals Detects business-level errors that technical validation may miss.

Conclusion

By following the above steps, you can build a self-updating report from a folder of files with Power Query. Power Query’s folder connector transforms a repetitive reporting task into a reusable data pipeline. By combining monthly files, standardizing their structures, and tracking problematic workbooks, you can build a report that remains reliable even as new data arrives. Once the setup is complete, your monthly reporting workflow becomes as simple as saving the latest file in the designated folder and clicking Refresh All.

Get FREE Advanced Excel Exercises with Solutions!

Shamima Sultana
Shamima Sultana

Shamima Sultana has been working with the ExcelDemy project for 4+ years. She has written and reviewed 1,500+ articles for ExcelDemy and has led several teams in Excel VBA and content development. She currently works as the Technical Content Specialist and Data Analyst for ExcelDemy, Statology, and KDnuggets, and oversees the site's technical content, forum, and YouTube content. Her work and learning interests range from automation in Microsoft Office, Google Workspace, and Excel to data analysis, data science,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Close the CTA

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo