Unpivot Excel Tables with Power Query for PivotTables and Maps
Question details
Convert department columns into rows and connect related tables for analysis in PivotTables, maps, or a Power Pivot data model.

- Product
- Microsoft Excel Power Query and Power Pivot
- Device & OS
- not provided
- Scenario
- Two tables contain related department data in different layouts, and the user wants to analyze them together.
- Observed behavior
- A normalized table and a unique department bridge provide a structure for filtering and analyzing both tables.
Identify the columns that represent departments and the columns that identify each record. Check that department names are spelled consistently across both tables and that any map source includes a geographic field.
Unpivot department columns and create a bridge table
Use this approach when department names appear as column headers and neither data table has a unique department column for a direct relationship.
Select a cell in the wide table in Excel, then choose Data > From Table/Range. Confirm the table range and headers if prompted.
In Power Query Editor, select the department columns, then choose Transform > Unpivot Columns. Keep record identifiers and other descriptive columns unselected.
Double-click the Attribute header and rename it Department. Rename Value to Count or another appropriate measure, and check the data types using the icons beside the headers.
Choose Home > Close & Load > Close & Load To, select Only Create Connection, and check Add this data to the Data Model. Prepare and load the other table similarly, ensuring it has a Department column.
In Power Query, create reference queries from the two tables, keep only each Department column, and use Home > Append Queries to combine them. Select Department, choose Home > Remove Rows > Remove Duplicates, remove blank names, and load the result to the Data Model.
Open Power Pivot > Manage and use Diagram View to connect the bridge table's unique Department column to the Department column in each fact table. Create a PivotTable from the Data Model and use the bridge Department field for shared filtering. For a map, include a suitable geographic field.

Explore spreadsheet data with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for opening and analyzing spreadsheets. Its Excel format support makes it easier to move existing files, but it does not fix Excel Power Query or Power Pivot issues.

Frequently Asked Questions
Why should I unpivot department columns?
Unpivoting turns department headers into values in one Department column, with their measures in another column. This makes the data easier to group and filter in a PivotTable.
Why do I need a department bridge table?
If departments repeat in both data tables, neither Department column is suitable as the unique side of a relationship. A bridge with one row per department can connect to both tables in the Data Model.
How do I include the normalized table in the Data Model?
In Power Query Editor, choose Home > Close & Load > Close & Load To, then select Only Create Connection and check Add this data to the Data Model.
Can I make a map using department names alone?
A map needs recognizable geographic information, such as a country, state, city, or coordinates. Include a suitable geographic field in the source data before creating the map.
Will a department filter affect both tables?
It can if the bridge has unique department names and valid relationships to both tables. Use the Department field from the bridge in the PivotTable filter, row area, or slicer.




