Horizontal and Vertical filter

Gvlewis81

Board Regular
Joined
Feb 5, 2013
Messages
202
Office Version
  1. 365
Platform
  1. Windows
Hi All,

it's been awhile since i've posted here and always found it so helpful.

I have a table similar to below. Vertically it has a list of subjects. Horizontally it has peoples names. Is there a way of being able to do this in a pivot table? I want to create a Radar graph where i can see everyone, or people individually. There are two types activity in the table with multiple Activities. The scoring is a capability score. So i'd like to be able to filter the type of activity, the activity itself and then by the person.

I'm really basic with pivot tables and they do blow my mind a bit!

Help appreciated.

Gareth

Type of ActivityActiviyPerson 1Person 2Person 3
TechnicalBe able to do this335
TechnicalBe able to do that343
LeadershipBe able to do the other333
LeadershipBe able to do some more324
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
To Pivot it you'd need to transform the data like this:

Type of ActivityActivityPersonNumber
TechnicalBe able to do thisPerson 1
3​
TechnicalBe able to do thisPerson 2
3​
TechnicalBe able to do thisPerson 3
5​
TechnicalBe able to do thatPerson 1
3​
TechnicalBe able to do thatPerson 2
4​
TechnicalBe able to do thatPerson 3
3​
LeadershipBe able to do the otherPerson 1
3​
LeadershipBe able to do the otherPerson 2
3​
LeadershipBe able to do the otherPerson 3
3​
LeadershipBe able to do some morePerson 1
3​
LeadershipBe able to do some morePerson 2
2​
LeadershipBe able to do some morePerson 3
4​


This code should do it (bit rusty but tested ok)

VBA Code:
Sub TransormData()

Dim sht As Worksheet
Dim colnum As Long
Dim LastRow As Long
Dim LastRow2 As Long
Dim FirstRow As Long
Dim FirstRow2 As Long
Dim RowCount As Long

Set sht = ActiveSheet

Columns("C:C").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromLeftOrAbove '
    
colnum = 4

Range("C1") = "Person"

FirstRow = 2
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
Range("C" & FirstRow & ":C" & LastRow).Value = Cells(1, colnum)
RowCount = LastRow - FirstRow + 1
colnum = 5


Do Until Cells(1, colnum) = ""
Range("A" & FirstRow & ":B" & LastRow).Copy Range("A" & sht.Cells(sht.Rows.Count, "A").End(xlUp).Row + 1)

LastRow2 = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
FirstRow2 = LastRow2 - RowCount + 1
Cells(1, colnum).Copy Range("C" & FirstRow2 & ":C" & LastRow2)
Range(Cells(FirstRow, colnum), Cells(LastRow, colnum)).Copy Range("D" & FirstRow2 & ":D" & LastRow2)
colnum = colnum + 1
Loop

Range("E:EZ").ClearContents
Range("D1").Value = "Score"



End Sub
 
Upvote 0
An alternative to getting the data ready for Pivot Table is to employ Power Query. Here is the Mcode that produces the same result as shown below which is the same as Post #2

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Type of Activity", type text}, {"Activiy", type text}, {"Person 1", Int64.Type}, {"Person 2", Int64.Type}, {"Person 3", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Type of Activity", "Activiy"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

Book7
ABCD
1Type of ActivityActiviyAttributeValue
2TechnicalBe able to do thisPerson 13
3TechnicalBe able to do thisPerson 23
4TechnicalBe able to do thisPerson 35
5TechnicalBe able to do thatPerson 13
6TechnicalBe able to do thatPerson 24
7TechnicalBe able to do thatPerson 33
8LeadershipBe able to do the otherPerson 13
9LeadershipBe able to do the otherPerson 23
10LeadershipBe able to do the otherPerson 33
11LeadershipBe able to do some morePerson 13
12LeadershipBe able to do some morePerson 22
13LeadershipBe able to do some morePerson 34
Sheet2
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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