Creating a Pivot Table from rows of data

andybrown115

New Member
Joined
Jul 13, 2017
Messages
9
icon4.png
I struggled to word the title of this thread properly... so here goes the explanation.

I have a set of system-exported data that shows me how much margin/profit we make on a particular timesheet that comes in from some of our contractors. The deals that are done are split between our sales consultants in our timesheet system. so a timesheet that makes us £100 may be split 70/30 between two consultants - so one consultant would have £70 with the other getting £30 against their target for the week.

What I am struggling with is the way the data comes out and then populating that into a pivot table. This is what comes out:

[TABLE="class: head"]
<tbody>[TR="bgcolor: #E0E0F0"]
[TH][/TH]
[TH]
A
[/TH]
[TH]
B
[/TH]
[TH]
C
[/TH]
[TH]
D
[/TH]
[TH]
E
[/TH]
[TH]
F
[/TH]
[TH]
G
[/TH]
[TH]
H
[/TH]
[TH]
I
[/TH]
[TH]
J
[/TH]
[TH]
K
[/TH]
[TH]
L
[/TH]
[TH]
M
[/TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
1
[/TD]
[TD]Contractor[/TD]
[TD]Margin[/TD]
[TD]CON1[/TD]
[TD]CON2[/TD]
[TD]CON3[/TD]
[TD]PERC1[/TD]
[TD]PERC2[/TD]
[TD]PERC3[/TD]
[TD]SPLIT1[/TD]
[TD]SPLIT2[/TD]
[TD]SPLIT3[/TD]
[TD]Invoice Week[/TD]
[TD]Timesheet Week[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
2
[/TD]
[TD]Bloggs, Joe[/TD]
[TD]
105.69​
[/TD]
[TD]
KG​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
100​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
105.69​
[/TD]
[TD]
-​
[/TD]
[TD]
-​
[/TD]
[TD]
04/03/2018​
[/TD]
[TD]
07/01/2018​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
3
[/TD]
[TD]Wiggins, Bradley[/TD]
[TD]
204.50​
[/TD]
[TD]
KG​
[/TD]
[TD]
RA​
[/TD]
[TD][/TD]
[TD]
70​
[/TD]
[TD]
30​
[/TD]
[TD][/TD]
[TD]
143.15​
[/TD]
[TD]
61.35​
[/TD]
[TD]
-​
[/TD]
[TD]
04/03/2018​
[/TD]
[TD]
14/01/2018​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
4
[/TD]
[TD]Knightly, Kiera[/TD]
[TD]
199.00​
[/TD]
[TD]
RA​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
100​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
199.00​
[/TD]
[TD]
-​
[/TD]
[TD]
-​
[/TD]
[TD]
04/03/2018​
[/TD]
[TD]
21/01/2018​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
5
[/TD]
[TD]Jones, Dave[/TD]
[TD]
203.00​
[/TD]
[TD]
RA​
[/TD]
[TD]
KG​
[/TD]
[TD]
QSW​
[/TD]
[TD]
50​
[/TD]
[TD]
15​
[/TD]
[TD]
35​
[/TD]
[TD]
101.50​
[/TD]
[TD]
30.45​
[/TD]
[TD]
71.05​
[/TD]
[TD]
04/03/2018​
[/TD]
[TD]
07/01/2018​
[/TD]
[/TR]
</tbody>[/TABLE]

So Bradley's timesheet value is £204.50 split 70/30 between consultants KG and RA respectively.

I'd not have an issue pivoting that to show the data if each split was shown on a separate row. But as it's across columns I'm a little baffled. I can neither think of a good formula to append to the data table nor a way to arrange the pivot table.

'I want' the pivot table to look like the below. The split margin is the sum of each consultant's initials against the SPLIT1 SPLIT2 or SPLIT3 as appropriate.

PIVOT TABLE
[TABLE="class: head"]
<tbody>[TR="bgcolor: #E0E0F0"]
[TH][/TH]
[TH]
A
[/TH]
[TH]
B
[/TH]
[TH]
C
[/TH]
[TH]
D
[/TH]
[TH]
E
[/TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
7
[/TD]
[TD]Invoice Week[/TD]
[TD]Consultant[/TD]
[TD]
Contractor​
[/TD]
[TD]Timesheet Week[/TD]
[TD]Split Margin[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
8
[/TD]
[TD]
04/03/2018​
[/TD]
[TD]KG[/TD]
[TD]Bloggs, Joe[/TD]
[TD]
07/01/2018​
[/TD]
[TD]
105.69​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
9
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Wiggins, Bradley[/TD]
[TD]
14/01/2018​
[/TD]
[TD]
143.15​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
10
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Jones, Dave[/TD]
[TD]
07/01/2018​
[/TD]
[TD]
30.45​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
11
[/TD]
[TD][/TD]
[TD]RA[/TD]
[TD]Wiggins, Bradley[/TD]
[TD]
14/01/2018​
[/TD]
[TD]
61.35​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
12
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Knightly, Kiera[/TD]
[TD]
21/01/2018​
[/TD]
[TD]
199.00​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
13
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Jones, Dave[/TD]
[TD]
07/01/2018​
[/TD]
[TD]
101.50​
[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #E0E0F0"]
14
[/TD]
[TD][/TD]
[TD]QSW[/TD]
[TD]Jones, Dave[/TD]
[TD]
07/01/2018​
[/TD]
[TD]
71.05​
[/TD]
[/TR]
</tbody>[/TABLE]

Slicers would be added for each piece of pivot data used.

I've answered a question on this forum this morning in the hope that my kindness will pay forward. Karma.
icon6.png


Thanks in advance! :-)
icon14.png
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Your first table structure is nonnormal mixed with normal data. Unless the normal source tables are available for writing queries, you have to unpivot using BI tools or this method for standalone Excel:

https://www.youtube.com/watch?v=xmqTN0X-AgY

Then you can pivot:


Excel 2010
ABCDEFGHIJKL
1RowInvWeekTimeWeekColumnValueValue2
2Bloggs, Joe3/4/20181/7/2018AKG105.69InvWeekValueRowTimeWeekSum of Value2
3Bloggs, Joe3/4/20181/7/2018B3/4/2018KGBloggs, Joe1/7/2018105.69
4Bloggs, Joe3/4/20181/7/2018CJones, Dave1/7/201830.45
5Wiggins, Bradley3/4/20181/14/2018AKG143.15Wiggins, Bradley1/14/2018143.15
6Wiggins, Bradley3/4/20181/14/2018BRA61.35QSWJones, Dave1/7/201871.05
7Wiggins, Bradley3/4/20181/14/2018CRAJones, Dave1/7/2018101.5
8Knightly, Kiera3/4/20181/21/2018ARA199Knightly, Kiera1/21/2018199
9Knightly, Kiera3/4/20181/21/2018BWiggins, Bradley1/14/201861.35
10Knightly, Kiera3/4/20181/21/2018C
11Jones, Dave3/4/20181/7/2018ARA101.5
12Jones, Dave3/4/20181/7/2018BKG30.45
13Jones, Dave3/4/20181/7/2018CQSW71.05
Sheet12
 
Last edited:
Upvote 0
Excellent reply... the standalone Excel way worked brilliantly.

Interestingly, though, I've just started working with Power BI. I have my head around it in a simplistic fashion, but had't realised it would be an option for this stuff. Using that would be infinitely better than amending the core data.

To that end, I've spent the past two hours learning how to do it in Power BI, and the result is beautiful and slick

Thanks very much for giving both options. Both helped, and both work!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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