Calculating the Sum of Averages in a Pivot Table

arveearv

New Member
Joined
Apr 29, 2013
Messages
12
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
Hi:

This problem has been nagging at me for several days. There must be a way to do this, but I'm just not seeing it. (I'm using Excel 2007.)

A landscaping company has given me their data. At the beginning of the year, each of their client signs up for one of several pre-paid plans. As work needs to be done, the company sends in a contractor to do the work, then the company pays the contractor. The company wants to measure the profit and loss from each of their customers.

Here's a sample of the raw data. Each row represents a service provided to a customer. Note that each customer's Pre-Paid Plan field gets redundant: every time the customer is listed, it's always the SAME plan amount associated with that client.
Excel 2007
ABCDEF
1RegionCustomerPre-Paid Plan AmountService Call DateServiceContractor Cost
2EastSIMPSON$300.001/19/2012Waste Removal$60.00
3EastSIMPSON$300.004/30/2012Edging - small$100.00
4EastWEBBER$550.005/15/2012Watering$85.00
5EastWEBBER$550.006/11/2012Waste Removal$60.00
6WestBABCOCK$550.006/7/2012Planting - Med$120.00
7WestABRAMS$400.001/18/2012Watering$85.00
8WestABRAMS$400.006/1/2012Mulching$80.00

<tbody>
</tbody>
short version



And here's the ideal pivot table that the company wants to see, but that I'm not able to generate:
Excel 2007
GHIJ
10RegionTotal Pre-Paid ReceivedTotal Contractor CostNet Loss/Gain
11East$850 (i.e. Simpson-$300; Webber-$550)$305$545 (i.e. $850-$305)
12West$950 (i.e. Babckock-$550; Abrams-$400)$285$665 (i.e. $950-$285)

<tbody>
</tbody>
short version


The "Total Contractor Cost" makes sense. It's just the total amount that the company has paid out, broken down according to the pivot table definition. The problem is generating the Total Pre-Paid Recieved -- the 2 customers in the East Region have paid $300 and $550. So the income from the East Region should be $850, but when I do this as a Pivot table, that value is $3,050 - the sum of all the pre-paid values every time they appear in the data sheet. Then of course there's the problem of generating that final column, which is the difference between the
totals in Columns H and I.

Any ideas?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Wow, Smitty! Thanks.

OK, so from the link you provided, I modified the formula to match my data: (=IF(SUMPRODUCT(($B$2:$B2=B2)*($C$2:$C2=C2))>1,0,1). I don't know how it works (yet) but it works, so I have put a marker of "1" in my source data for every first occurrence of a unique value. Great.

So, when I select for the unique values only, I get this pivot table so far:
Excel 2007
GHIJ
22
23Row LabelsSum of Pre-Paid Plan Amount
24East850
25West950
26Grand Total1800
27

<tbody>
</tbody>
short version
Column "I" looks great. And now I want to add columns that are based on all the values (not just the unique ones), as in Column "I" in my ideal pivot table in my original post. Will this be possible in the same pivot table?

Thanks again.
 
Last edited:
Upvote 0
This is probably the closest you would get with a normal pivot table:

Excel 2012
ABCD
3Row LabelsPre-Paid Plan AmountContractor CostNet Loss/Gain
4East$1,700.00 $305.00 $1,395.00
5SIMPSON$600.00 $160.00 $440.00
6WEBBER$1,100.00 $145.00 $955.00
7West$1,350.00 $285.00 $1,065.00
8ABRAMS$800.00 $165.00 $635.00
9BABCOCK$550.00 $120.00 $430.00
10Grand Total$3,050.00 $590.00 $2,460.00

<COLGROUP><COL style="BACKGROUND-COLOR: #dae7f5"><COL><COL><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
</TBODY>
Sheet4
With a Calculated Field for Net Loss/Gain. Note that this method wouldn't require an intermediate column in the data.
 
Upvote 0
Hi:

Hmm... It makes sense, but the Pre-Paid Plan column is wrong because it assumes that the customer paid for a full-year plan on EACH contractor visit. We'd need a table that somehow contains Column "I" of the example in my previous post, and Column "C" in your reply above.

What if we generated this table (where "1" represents the first unique occurrence of a customer):
Excel 2007
ABCDEFG
22
23Column Labels
24Sum of Pre-Paid Plan AmountSum of Contractor CostTotal Sum of Pre-Paid Plan AmountTotal Sum of Contractor Cost
25Row Labels0101
26East8508501601451700305
27SIMPSON30030010060600160
28WEBBER55055060851100145
29West400950802051350285
30ABRAMS4004008085800165
31BABCOCK550120550120
32Grand Total125018002403503050590

<tbody>
</tbody>
AlmostIdeal
...and could then somehow hide columns "B", "D", "E" and "F"? Is that possible in a pivot table?
 
Last edited:
Upvote 0
If you add your column I to the original data set then you can include it in the PT. If you want to hide PT columns and still need the column itself to be in the PT, then it's as easy as just hiding the column.
 
Upvote 0

Forum statistics

Threads
1,221,519
Messages
6,160,294
Members
451,636
Latest member
ddweller151

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