Download the Advanced Unpivot Workbook
Get the Excel file from the video with the sales report with Actual and Budget headers, so you can build the Power Query steps yourself and test the refresh with a new month.
The Report and the Three Challenges
Let’s look at what we have been given to work with.

What the Report Looks Like
- We have a list of customer’s names, article descriptions, and sales.
- Customer names are only listed for the first article description. It is assumed that all successive article descriptions belong to the noted customer until a subtotal row & new customer name is encountered.
- A total row occurs after all transactions for a single customer.
- A Grand Total row occurs at the bottom of the data.
- Sales are shown by month. The month headers are real dates, formatted to show the month name.
- Each month has a value for Actual along with a value for Budget.
- The scenario headings Actual and Budget sit above their months, so the report has two header rows.
What the Result Should Look Like
- Display a table with the records categorized by the scenario.
- Exclude the total/grand total rows from the final report.
- The report needs to accommodate expansion when new months are added to the data.

Step 1: Use Center Across Selection Instead of Merged Cells
Notice that the scenario headings Actual and Budget are centered across the month headings, but the cells are not merged.

When we bring the data into Power Query, we don’t want to disrupt this look.
Instead of merging the cells to center the scenario label, a better approach is to use the “Center Across Selection” alignment option.
This feature can be found by highlighting the desired cells and pressing CTRL-1. In the Format Cells dialog box, under the Alignment tab is a dropdown for Horizontal. It is from this dropdown that the Center Across Selection option can be found.

The advantage is that the range can become a proper Excel table and still look the same. Excel tables don’t allow merged cells. If you turn a range with merged cells into a table, Excel unmerges them and the report loses its look.
Step 2: Split the Window to See the Totals
Because the Grand Total row is so very far from the header rows, we will utilize a split-window view to keep track of the top and bottom of the table simultaneously.
Select View (tab) -> Window (group) -> Split.

We can scroll the top and bottom windows separately giving us a view of the extents of the data.

Step 3: Turn the Report Into a Table Without Headers
- Select a cell in the data, press Ctrl+A to select the entire data range.
- Press Ctrl+T to create an Excel table and uncheck My table has headers, so Actual and Budget don’t become column headers.

- Return the table to its original look by clearing the color formatting. This is done by selecting Table Design (tab) -> Table Styles (group) -> and selecting the None style in the upper-left corner of the style library.

- Remove the automatically applied generic Header Row by deselecting Table Design (tab) -> Table Style Options (group) -> Header Row.

- Rename the table “TCustomer” (Table Design (tab) -> Properties (group) -> Table Name).

- Load the data into Power Query as a Table by selecting Data (tab) -> Get & Transform Data (group) -> From Table/Range.

Step 4: Fill Down the Customer Names
- Start by giving the query a better name. In the Query Settings panel (right), change the current name of “TCustomer” to “DataProper”.

- Remove the automatically applied Changed Type and Promoted Headers steps from the query.

- Fill in the missing customer names for each blank row by performing a Fill Down operation on the customer names (Column1). Select Transform (tab) -> Any Column (group) -> Fill -> Down.

Step 5: Merge, Transpose and Unpivot the Headers
If our headers were confined to a single row, we could proceed to the unpivoting portion of the process.
Because we need to get the scenario names Actual and Budget associated with each month, we need to do a bit of processing on the headers first.
- Merge the customer names (Column1) and the article descriptions (Column2) using a semicolon as the delimiter into a new column named “Merged”. Select Column1 and Column2 and click Transform (tab) -> Text Column (group) -> Merge Columns. The necessity of this step will soon become obvious.
NOTE: The separator can be any character as long as it doesn’t appear in the data.
If you only need to flip rows and columns once, without a refresh, these 3 ways to transpose data in Excel are faster.
This works with more than two anchor columns and more than two header rows too. Merge all anchor columns into one, and the rest of the steps stay the same.


- Transpose the table by selecting Transform (tab) -> Table (group) -> Transpose.

- Perform a Fill Down operation on the scenario names (Column1).
- Promote the first row as a header row (Transform (tab) -> Table (group) -> Use First Row as Headers).

- Remove the automatically applied Changed Type step.
- Select the first two columns (scenario and date) and click Transform (tab) -> Any Column (group) -> Unpivot Columns -> Unpivot Other Columns.

- Select the Attribute column and split the column by delimiter by selecting Transform (tab) -> Text Column (group) -> Split Column -> By Delimiter.

- The delimiter is a semicolon and will be split at each occurrence.

- Remove the automatically applied Changed Type.
- Rename the columns to Scenario, Date, Customer, Article and Sales Value.


- Filter the Customer column to keep rows that do not end with “Total”.

- Change the data types: Text for Scenario, Customer and Article, Date for Date (this drops the time part) and Currency for Sales Value.
- Reorder the columns as Customer, Article, Scenario, Date and Sales Value.
- Close & Load the results to an Excel Table.


Step 6: Add a New Month and Refresh
We need to ensure that when new months of data are added, the table updates accordingly.
To test it, insert a column for April Actual inside the table, right after March Actual. Then add April Budget at the end of the table so the table expands. Right-click the output table and choose Refresh.

Once the data is refreshed, we can see the April transaction in the output table.

The same refresh idea works across files. See how to combine multiple Excel files into one with Power Query.
Step 7: Remove Empty Sales Values
There are rows in our table where there was no sale for an item in a given month.

Why didn’t Unpivot remove them? Unpivot skips null cells, but some empty cells come in as empty text, not null. Once you change Sales Value to Currency, those empty cells turn into null. So add the filter after the Changed Type step.
We can add a step to the query that removes any rows where the sale is missing.
- Right-click the query and select Edit.
- Filter out the null values from the Sales Value column (uncheck null in its filter drop-down).
- Close & Load the results to an Excel Table.

The results are as follows:

Download the Advanced Unpivot Workbook
Get the Workbook From the Video
Practice the unpivot steps on the same report I use in the video.
Frequently Asked Questions
How do I unpivot data with multiple header rows in Excel?
Load the data into Power Query without headers, fill down the anchor columns and merge them into one column. Transpose the table, fill down the top header row, promote the first row to headers and use Unpivot Other Columns. Then split the merged column back apart.
Why do I need to merge the columns before transposing?
Unpivot needs a single header row. Merging the anchor columns into one column means that after the transpose they become a single header, so the scenario and month rows can turn into normal columns.
Why should I use Center Across Selection instead of merged cells?
Excel tables do not allow merged cells. If you create a table from a range with merged cells, Excel unmerges them. Center Across Selection gives the same look without merging, so the report keeps its layout.
How do I remove total rows in Power Query?
Open the filter on the customer column, choose Text Filters and Does Not End With, and type Total. This removes the customer totals and the grand total in one step.
Will the query pick up new months automatically?
Yes, as long as the new columns are inside the Excel table. Add the new month columns to the table, then right-click the output and choose Refresh.
Why do empty cells still show up after unpivoting?
Unpivot skips null cells, but some empty cells come in as empty text. After you change the value column to a number or currency type they turn into null, so filter out null in that column after the type change.
Leila Gharani
Founder of XelPlus and ten-time Microsoft MVP. Leila helps over 500,000 professionals master Excel, Power BI, and data automation through practical, real-world training.








