Pivot Column Question

Craigc3814

Board Regular
Joined
Mar 7, 2016
Messages
217
I assume this is a very easy thing to do and I am just missing what I want for some reason. I am using PowerQuery and Excel 2016 (Office 365)

I have 5 columns of data that look like below

Location Usage Date BMD IMD PMD
Home January 50 100 100
Home February 75 80 80


I want to transform (I assume Pivot with no aggregation) to this

Location Type January February March April......
Home BMD 50 75
Home IMD 100 80
Home PMD 100 80
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
if this is your source data (blue table)

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Location_Usage[/td][td=bgcolor:#5B9BD5]Date[/td][td=bgcolor:#5B9BD5]BMD[/td][td=bgcolor:#5B9BD5]IMD[/td][td=bgcolor:#5B9BD5]PMD[/td][td][/td][td=bgcolor:#70AD47]Location_Usage[/td][td=bgcolor:#70AD47]Attribute[/td][td=bgcolor:#70AD47]January[/td][td=bgcolor:#70AD47]February[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Home[/td][td=bgcolor:#DDEBF7]January[/td][td=bgcolor:#DDEBF7]
50​
[/td][td=bgcolor:#DDEBF7]
100​
[/td][td=bgcolor:#DDEBF7]
100​
[/td][td][/td][td=bgcolor:#E2EFDA]Home[/td][td=bgcolor:#E2EFDA]BMD[/td][td=bgcolor:#E2EFDA]
50​
[/td][td=bgcolor:#E2EFDA]
75​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]Home[/td][td]February[/td][td]
75​
[/td][td]
80​
[/td][td]
80​
[/td][td][/td][td]Home[/td][td]IMD[/td][td]
100​
[/td][td]
80​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td=bgcolor:#E2EFDA]Home[/td][td=bgcolor:#E2EFDA]PMD[/td][td=bgcolor:#E2EFDA]
100​
[/td][td=bgcolor:#E2EFDA]
80​
[/td][/tr]
[/table]




Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Location_Usage", type text}, {"Date", type text}, {"BMD", Int64.Type}, {"IMD", Int64.Type}, {"PMD", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date", "Location_Usage"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Date]), "Date", "Value", List.Sum)
in
    #"Pivoted Column"[/SIZE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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