# Incorrect Count Subtotal in Pivot Table Calculated Field

##### New Member
Hello,

I have a report with a date slicer that returns, by sales manager, by sales rep, by account, the current period revenue and prior year revenue for the sliced date range. I need to add a column that counts the number of accounts with revenue in the current period. The data source is such that adding a helper column to it almost certainly won't help. My approach so far is to insert calculated field, IF(Total Revenue>0,1,0), which returns a 1 next to each advertiser with current period revenue. My problem is that, for each sales rep, it doesn't return a subtotal of the number of accounts under him/her with a 1 next to them -- it just returns a 1, and same for sales manager and same for grand total. I need the calculated field to essentially sumifs itself at the subtotal and grand total levels.

Can anyone help me return a correct count subtotal in a Pivot Table calculated field?

 SM AE Advertiser Current Revenue # Accounts SM1 244,542 (sum of all SM's accounts) SM1 AE1 6,745 2 SM1 AE1 Advertiser 1 - - SM1 AE1 Advertiser 2 3,519 1 SM1 AE1 Advertiser 3 - - SM1 AE1 Advertiser 4 - - SM1 AE1 Advertiser 5 3,226 1

<tbody>
</tbody>

### Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use \$ signs: \$V\$2:\$Z\$99 will always point to V2:Z99, even after copying

##### New Member
FYI, after digging deeper I'm pretty sure there's no way for a calculated field to help me with this, because calculated fields apply the same formula to subtotals and total columns as they do to other columns. My solution is pretty complicated. I'm going to create a separate sheet with 19 different value calculations based on the 19 different likely date selections (1 for each month, quarter, half, and full year), and I'm going to return the filtered values in a way that returns the values of the correct date case into the pivot table source data. final piece is to add a macro that automatically updates the pivot table when changes are made to the source data. heh.

Replies
5
Views
226
Replies
5
Views
150
Replies
4
Views
248
Replies
0
Views
448
Replies
1
Views
268

1,127,736
Messages
5,626,596
Members
416,194
Latest member
Dhisilva_aguiar

### 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.

### Which adblocker are you using?

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

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