Total of weighted average based on count of unique rows (But in a pivot table)

Milbourn

New Member
Joined
May 27, 2014
Messages
44
Hi,


I am trying to find the SUM of the WEIGHTED AVERAGE, based on dividing the COUNT of unique combination of values in a row based on three values (COL A, B, and C) DIVIDED by COL D in a pivot table.


Multiple occurrences of data in COL A B and C, causes a duplicate in COL D which I am have a pivot table tracking the grand totals on a separate sheet.


I have a working formula to correct for these duplicates but I have no idea how to transfer this onto a pivot table.


The formula is


SUMPRODUCT(1/COUNTIFS(Data!A2:A36,Data!A2:A36,Data!B2:B36,Data!B2:B36,Data!C2:C36,Data!C2:C36),Data!D2:D36),


which I would have assumed would transfer over to


SUMPRODUCT(1/COUNTIFS(COL A,COL A,COL B,COL B,COL C,COL C),COL D) on the pivot table but it does not.


Can anyone tell me what I am doing wrong?
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Sorry to bump, I've had a bit further look into it and there is apparently a problem with using countifs/sumifs on pivot tables. The way it looks like to get round it is using SQL but I dont know anything about that unfortunately. Is there any workaround available?
 
Upvote 0
Sure thing, thanks for responding. I’m not sure how to attach files in this forum [...]

Try to post a small scal;ed-down sample along with the desired results. Attachments lists a few methods for posting sample exhibits which do not require retyping and the add-in https://app.box.com/s/soezox25h3w0q5s4rcyl is also a method for posting an exhibit (Note that an image or a link to a storage site like dropbox or onedrive etc. does not provide a permanent record.). Mind you a forum without a permanent record is not of much value.
 
Upvote 0
Sorry I can't really download any attachments such as these onto any of my current PC. Is there another upload site that would be more permanent and better accepted?
 
Upvote 0
Hi again!

I have not come up with a solution to this yet, so was hoping to reopen this thread and ask for help!


So I am trying to have a pivot table for the below information where I can get the sum totals for Identifier A or B, but this total would only count the duplicate rows once. I have the formula for the total (below), but have no idea how to do this on a pivot. Would anyone be able to help?




ABCDE
1Identifier aIdentifier bDate.1Date.2Values
2Identifier 1Apples11/02/201624/02/20163329
3Identifier 2Apples11/02/201624/02/20161249
4Identifier 2Apples11/02/201624/02/20161249
5Identifier 3Apples21/04/201604/05/20161543
6Identifier 3Apples21/04/201604/05/20161543
7Identifier 3Apples21/05/201604/06/20162000
8Identifier 4Apples21/04/201604/05/20161840
9Identifier 4Bananas05/05/201618/05/20162832
10Identifier 5Bananas07/04/201620/04/20164843

<tbody>
</tbody>

Sum of Values EXCLUDING DUPLICATES: 15,788

<tbody>
</tbody>


Code:
=SUMPRODUCT(1/COUNTIFS(A2:A10,A2:A10,C2:C10,C2:C10,D2:D10,D2:D10),E2:E10)
 
Upvote 0
The red records are duplicates I wish to exclude from the grand total.

The total should be 17,636, apologies for the confusion, I changed the data set to make it clearer but forgot to update the total!
 
Upvote 0
The red records are duplicates I wish to exclude from the grand total.

The total should be 17,636, apologies for the confusion, I changed the data set to make it clearer but forgot to update the total!

Row\Col
A​
B​
C​
D​
E​
F​
1​
Identifier a Identifier b Date.1 Date.2 Value Value*UNIQ
2​
Identifier 1 Apples 2/11/2016 2/24/2016 3329 3329
3​
Identifier 2 Apples 2/11/2016 2/24/2016 1249 624.5
4​
Identifier 2 Apples 2/11/2016 2/24/2016 1249 624.5
5​
Identifier 3 Apples 4/21/2016 5/4/2016 1543 771.5
6​
Identifier 3 Apples 4/21/2016 5/4/2016 1543 771.5
7​
Identifier 3 Apples 5/21/2016 6/4/2016 2000 2000
8​
Identifier 4 Apples 4/21/2016 5/4/2016 1840 1840
9​
Identifier 4 Bananas 5/5/2016 5/18/2016 2832 2832
10​
Identifier 5 Bananas 4/7/2016 4/20/2016 4843 4843

In F2 control+shift+enter, not just enter, and copy down:

=1/COUNT(IF(A2=$A$2:$A$10,IF(B2=$B$2:$B$10,IF(C2=$C$2:$C$10,IF(D2=$D$2:$D$10,1)))))*E2

Then run a pivot table on this extended source:

Row\Col
H​
I​
1​
Row LabelsSum of Value*UNIQ
2​
Identifier 1
3329​
3​
Identifier 2
1249​
4​
Identifier 3
3543​
5​
Identifier 4
4672​
6​
Identifier 5
4843​
7​
Grand Total
17636
 
Upvote 0

Forum statistics

Threads
1,215,139
Messages
6,123,263
Members
449,093
Latest member
Vincent Khandagale

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