Calculating averages in a pivot table using distinct count

Fitzy22

New Member
Joined
Jan 19, 2022
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to calculate averages per site requiring use of the distinct count function. I've used the following calculations to determine these averages:

- Total count (calculated using the sum total) - Column 2
- Survey count (calculated using distinct count) - Column 3
- Average count (calculated as column 2/column 3).

This provides an accurate calculation for SLT01 and SLT02, but I would like the grand total to divide by 14 rather than 7. Is there a way to determine the distinct count of a column using criteria in a second column? I think this may help.

Row LabelsTotal Count - Low tide survey eventLow tide survey countLow tide average count per transect
SLT01
107​
7​
15.28571429​
SLT02
36​
7​
5.142857143​
Grand Total
143​
7​
20.42857143​

I would also like to calculate the average count for each species detected in a survey (e.g., SLT01). As the number of surveys remains the same all individual species counts must still be divided by 7 (though this may change in future surveys). However, when I select the species, rather than still dividing the total count for each species by the total survey count, the pivot table instead divides the total count by the number of surveys the species was detected (refer table below).

Row LabelsTotal Count - Low tide survey eventLow tide survey countLow tide average count per transect
SLT01
Charadrius mongolus
3​
2​
1.50​
Charadrius ruficapillus
26​
5​
5.20​
Chroicocephalus novaehollandiae
3​
2​
1.50​
Ephippiorhynchus asiaticus
1​
1​
1.00​
Esacus magnirostris
4​
3​
1.33​
Gelochelidon nilotica
5​
3​
1.67​
Haematopus longirostris
9​
5​
1.80​
Hydroprogne caspia
2​
2​
1.00​
Numenius madagascariensis
17​
6​
2.83​
Numenius phaeopus
19​
4​
4.75​
Pluvialis fulva
9​
2​
4.50​
Pluvialis squatarola
8​
2​
4.00​
Tringa nebularia
1​
1​
1.00​
SLT02
(blank)
6​
1​
6.00​
Charadrius ruficapillus
6​
2​
3.00​
Esacus magnirostris
1​
1​
1.00​
Haematopus longirostris
2​
1​
2.00​
Nil observed
0​
3​
0.00​
Numenius madagascariensis
6​
1​
6.00​
Numenius phaeopus
15​
4​
3.75​
Grand Total
143​
7​
20.42857143​

Is there a simple way of making the pivot table run the calculation in this way? I think the easiest way is probably to add an additional column in the dataset, which is an n value (i.e., number of sites per survey), but I'm curious to see if there is a workaround within the pivot table field calculation. Datasets that I receive may not readily have this information included.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi,

You are absolutely right !!!

By far, the easiest solution is to have a helper column in your database which will allow the Pivot Table to generate your report in a flash 😀
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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