Generalised unpivoting
Overview
This article explains how to create a generalised solution for unpivoting tables with any levels of hierarchies.
The general steps for achieving this are illustrated below:
![](images/generalised-unpivoting-01a.png)
![](images/generalised-unpivoting-01b.png)
Next, we show what happens in detail, step by step:
Steps
1. Load the Data
- Get to the source data. Here, the source data is a sparse table with multiple hierarchies across columns and rows – and basically in a form that is not that useful for reporting.
![](images/generalised-unpivoting-02.png)
2. Fill Down text columns
- Apply the Fill Down columns 1, and 2
![](images/generalised-unpivoting-03.png)
3. Merge text columns
- Next, merge columns 1, 2, and 3, using a Colon (:) as the separator
![](images/generalised-unpivoting-04.png)
4. Transpose the data
- After this, Transpose the Data Table, as shown below:
![](images/generalised-unpivoting-05.png)
5. Fill Down on anchor columns
- Next, apply the Fill Down function to Columns 1, and 2
![](images/generalised-unpivoting-06.png)
6. Promote Headers
- Then, Promote Headers
![](images/generalised-unpivoting-07.png)
7. Unpivot the data
- After this, choose UnpivotOtherColumns, on the main anchor columns “::Color”, “::Parent Category”, and “Country:State/Region:City…”
![](images/generalised-unpivoting-08.png)
8. Split columns
- Then, split the Attribute column, using the Delimiter, Colon (:)
![](images/generalised-unpivoting-09.png)
9. Rename columns
- After this, rename columns to something more relevant and meaningful.
![](images/generalised-unpivoting-10.png)
You are DONE!
10. Close & Load
- Load the results into worksheet
The “sparse” summary table is now transformed into something that can be readily, and easily be put to better use.
![](images/generalised-unpivoting-11.png)
Feedback
Submit and view feedback