How to Automate Power Query Pivot Transformations for Weekly Reports in Excel
Question details
The user needs a reliable method to automate the transformation of weekly spreadsheet reports featuring complex, multilevel headers into a structured tabular data format.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Combining multiple weekly report spreadsheets that contain multilevel headers to automatically extract and produce standardized columns for Date, Place, Region, Actual Value, and Forecast Value.
- Observed behavior
- The user wants to eliminate repetitive manual formatting each week and achieve a fully automated data pipeline that generates flat, dashboard-ready tables instantly upon refresh.
Ensure all your weekly source files share a consistent layout and are stored together in a dedicated folder before establishing your Power Query connection.
Automate Report Transformations Using Power Query
Use Excel's Power Query to pull data from a folder, normalize multilevel headers, and automate the unpivoting process for your weekly reports without VBA.
Power Query (available in Excel 365) provides a robust interface to automate complex data transformations. By recording your formatting steps once, you can reuse the exact same logic every week simply by refreshing the query.
In Excel, navigate to the Data tab, click 'Get Data', choose 'From File', and select 'From Folder'. Locate the folder containing your weekly reports and click Combine & Transform Data.
In the Power Query Editor, remove any blank top rows. If you have multilevel headers, transpose the table, use 'Fill Down' to populate missing category labels, merge the header columns with a delimiter, and transpose the data back. Finally, click 'Use First Row as Headers'.
Select the fixed attribute columns (like Place and Region), right-click the header, and choose 'Unpivot Other Columns' to flatten your weekly data into a tabular structure.
Use the Transform tab features to extract text before your delimiter in the newly created Attribute column. Select and remove any unused fields, such as old Date/Forecast columns, using 'Table.RemoveColumns'.
Select the cleaned attribute column and choose 'Pivot Column' from the Transform tab. Set your Values column to calculate the appropriate metrics, producing clean columns for Actual Value and Forecast Value.
Assign the correct data types (e.g., Text, Date, Decimal) to each column using 'Table.TransformColumnTypes'. Click 'Close & Load' to push the automated data into an Excel sheet. To update next week, simply drop the new file into your folder and click 'Refresh All'.

Need a Fast & Free Alternative for Data Analysis?
While Microsoft Excel's Power Query is highly effective, the software itself can be expensive and resource-heavy. WPS Office offers a completely free, lightweight, and highly compatible spreadsheet alternative equipped with powerful built-in Pivot Tables to summarize your weekly data effortlessly.

Frequently Asked Questions
Can I automate weekly Excel reports without knowing how to write VBA macros?
Yes. Power Query enables you to automate data transformations visually through its interface. It automatically generates the underlying M code, completely eliminating the need to write complex VBA macros.
How do I ensure next week's file is automatically processed by Power Query?
When setting up your initial query, ensure you connect using 'From Folder' rather than 'From File'. Moving forward, simply save your new weekly spreadsheet into that exact folder, open your master dashboard, and click 'Refresh All' on the Data tab.
What is the best way to handle multilevel headers that span across merged cells?
In Power Query, merged cells often result in null values. You can resolve this by transposing the data, using the 'Fill Down' transformation to populate the null cells with the correct overarching category, merging the rows, and then transposing the table back to its original orientation before promoting the headers.




