Transforming Data into Tables
Reports and tables are different things
Section titled “Reports and tables are different things”A summary report is laid out for a person to read. It groups rows under headings, spreads values across columns and adds totals, so a reader can take in the picture at a glance. The same layout is awkward to analyse, because the facts are split between row headings, column headings and the cells where they cross. Filtering by one company, charting one category or adding a new period all mean working against the layout.
A table that is ready for analysis has a simpler shape:
- each column holds one kind of fact, such as a category, a person or an amount
- each row holds one observation, which here is one revenue figure
- there are no totals, because a PivotTable or a measure can work those out
This page reshapes a revenue report into that form. The report shows revenue by salesperson and client company down the side, and by parent category and category across the top:

The difficulty is that both axes have two levels of headings. The approach is to collapse each axis to a single column, unpivot, and then split the collapsed values apart again.
Step 1: load the report
Section titled “Step 1: load the report”- On the Data tab, choose Get Data, then From File, then From Workbook, and select
Data with incorrect design.xlsx. - Load the workbook into the editor. It lists the sheet and a defined name,
Revenues, which covers the report’s range.

- Click
Tablein theDatacolumn of theRevenuesrow to open the report’s data.

The editor shows something the formatted report hides: each salesperson’s block ends with a subtotal row, such as jae0 Total. These rows need removing later, along with the category subtotals that appear once the table is turned round.
Step 2: remove the grand total column
Section titled “Step 2: remove the grand total column”The last column is the grand total. Rather than remove it by name, add a step that removes whichever column is last:
= Table.RemoveColumns(Revenues_DefinedName,{List.Last(Table.ColumnNames(Revenues_DefinedName))})Table.ColumnNames lists the columns in order, List.Last picks the final one, and Table.RemoveColumns drops it. If a category is added to the report next month, the total column moves along one place, and the step still removes the right one.

Step 3: remove the grand total row
Section titled “Step 3: remove the grand total row”The grand total row is the last row. On the Home tab, choose Remove Rows, then Remove Bottom Rows, and remove 1 row.

Step 4: fill in the salesperson
Section titled “Step 4: fill in the salesperson”Each salesperson’s name appears only on the first row of their block, so the rows beneath it are null. Select Column1, then choose Fill, then Down on the Transform tab. Every company row now carries its salesperson.

Step 5: merge the two row headings into one
Section titled “Step 5: merge the two row headings into one”Select Column1 and Column2, then choose Merge Columns on the Transform tab, with Colon as the separator. The salesperson and company now sit in one column, as in jae0:Action Bicycle Specialists.

Step 6: turn the table round
Section titled “Step 6: turn the table round”On the Transform tab, choose Transpose. The column headings become rows, so the parent category and category now run down the first two columns, and each salesperson and company pair becomes a column.

Step 7: fill in the parent category
Section titled “Step 7: fill in the parent category”The parent category now has the same gaps as the salesperson had before, so select Column1 and choose Fill, then Down again.

Step 8: promote the headers
Section titled “Step 8: promote the headers”On the Home tab, choose Use First Row as Headers. The first two columns take the headers : and SalesPerson:CompanyName, and every other column is headed by a merged salesperson and company.

Step 9: unpivot
Section titled “Step 9: unpivot”Select the first two columns, then open the Unpivot Columns drop-down on the Transform tab and choose Unpivot Other Columns. Each revenue figure becomes its own row, with the column it came from in Attribute and the figure in Value. Empty cells are dropped along the way, because Unpivot skips nulls.

Unpivot Other Columns is the safer choice here, because it names only the columns to keep. New salespeople or companies in next month’s report are unpivoted without any change to the query.
Step 10: split the attribute again
Section titled “Step 10: split the attribute again”Select Attribute, then choose Split Column, then By Delimiter on the Transform tab, and choose Colon as the delimiter. The salesperson and company return to separate columns.

Step 11: rename and remove the subtotals
Section titled “Step 11: rename and remove the subtotals”Rename the columns in order:
Parent CategoryCategorySales PersonCompanyRevenue
Two kinds of subtotal are still in the data, and both need filtering out:
- Salesperson subtotals have a
Sales Personsuch asjae0 Total. FilterSales Personwith Text Filters, then Does Not Contain, and enterTotal. - Category subtotals have a
Parent Categorysuch asAccessories Total. Apply the same filter toParent Category.

Step 12: load the table
Section titled “Step 12: load the table”Choose Close & Load. The report is now a flat table with one revenue figure per row, ready for a PivotTable or the Data Model.

The pattern
Section titled “The pattern”The same sequence works for any report with two levels of headings on each axis:
- Remove the grand total column and row.
- Fill down the outer row heading.
- Merge the row headings into one column.
- Transpose.
- Fill down the outer column heading.
- Use the first row as headers.
- Unpivot every column except the column headings.
- Split the merged column back into its parts.
- Rename the columns and filter out the subtotals.
The next page extends this to reports with more levels of headings.