Sum Avg Based on Distinct Field

JPSailes

New Member
Joined
Mar 16, 2018
Messages
4
Not sure how best to ask as a subject line.

col Box has additional line level details (using color to demonstrate scenario) thus repeating size. I need to only count size one time for each unique box. So my total for size would be 11; avg size 2.2. Effectively remove duplicates.

Typically, I would use two pivots tables to solve. However, I believe there should be a better route via pivot calculation or power pivot. I'm new to power pivot and cannot find a solution that works.

I was thinking if average of distinct box then sum average. Or to state another way: sum distinct box size average.


BoxSizeColor
A2Red
A2Green
A2Blue
B1Green
B1Blue
C3Red
C3Blue
D2Red
D2Green
D2Blue
E3Red
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Book1 (version 1).xlsb
ABCDEFG
1BoxSizeColor365Older
2A2Red2.22.2
3A2Green
4A2Blue
5B1Green
6B1Blue
7C3Red
8C3Blue
9D2Red
10D2Green
11D2Blue
12E3Red
Sheet5
Cell Formulas
RangeFormula
F2F2=AVERAGE(INDEX(UNIQUE(A2:B12),,2))
G2G2=AVERAGE(IF(FREQUENCY(IF(A2:A12<>"",MATCH(A2:A12,A2:A12,0)),ROW(A2:A12)-ROW(A2)+1),B2:B12))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
Book1 (version 1).xlsb
ABCDEFG
1BoxSizeColor365Older
2A2Red2.22.2
3A2Green
4A2Blue
5B1Green
6B1Blue
7C3Red
8C3Blue
9D2Red
10D2Green
11D2Blue
12E3Red
Sheet5
Cell Formulas
RangeFormula
F2F2=AVERAGE(INDEX(UNIQUE(A2:B12),,2))
G2G2=AVERAGE(IF(FREQUENCY(IF(A2:A12<>"",MATCH(A2:A12,A2:A12,0)),ROW(A2:A12)-ROW(A2)+1),B2:B12))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
I'd like to do it within a pivot so I can include other information -- especially date.
 
Upvote 0
I loaded the table into the data model and created a measure that can be dropped into a pivot table.

Measure:
Code:
DA:=DIVIDE(CALCULATE(COUNTA([Box]),ALLEXCEPT(Table1,Table1[Box])),DISTINCTCOUNT([Box]),0)

And here's the result.

Book1 (version 1).xlsb
BC
3BoxDA
4A3
5B2
6C2
7D3
8E1
9Grand Total2.2
Sheet4
 
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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