Create an advanced pivot table

HairyBoatmen

New Member
Joined
Apr 24, 2023
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
I'd like to create a pivot table where column names and data values in the original data table become row headings and column headings in the pivot table:

1682344884596.png
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
A power query solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
    #"Duplicated Column" = Table.DuplicateColumn(#"Unpivoted Other Columns", "Attribute", "Attribute - Copy"),
    #"Removed Columns" = Table.RemoveColumns(#"Duplicated Column",{"ID"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Value]), "Value", "Attribute - Copy", List.Count),
    #"Reordered Columns" = Table.ReorderColumns(#"Pivoted Column",{"Attribute", "sm", "med", "lg"})
in
    #"Reordered Columns"

Book3
ABCDEFGHIJ
1IDEyesNoseEarsHandsAttributesmmedlg
2amedlgmedsmEars323
3bmedsmlgmedEyes332
4clgmedsmmedHands152
5dsmlgsmlgNose323
6esmsmmedmed
7fsmmedlgmed
8gmedsmlgmed
9hlglgsmlg
Sheet1
 
Upvote 0
Solution
That' s brilliant. Thanks so much Alan.

Is there no way to do this with normal pivot functionality? I'd prefer to have the ability to slice and drill down as I would with a more basic pivot table
 
Upvote 0
Once you unpivot the data in Power Query, then close and load it to a Pivot Table in native excel. Either way you need to have the underlying data in a normalized manner in order to Pivot the information.
 
Upvote 0

Forum statistics

Threads
1,216,153
Messages
6,129,176
Members
449,491
Latest member
maxim_sivakon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top