Conditional field in pivot table

tigerzen

Board Regular
Joined
Mar 8, 2023
Messages
209
Office Version
  1. 365
Platform
  1. Windows
Trying to calculate the number of sales that exceed a certain threshold, 30 in this example but would like to be able to make it variable by using a cell reference so we can vary the threshold and change it quickly to 40, 50 or any other amount. Anyway the existing pivot table simply returns 1 and clearly in January 2022 there are 2 values over 30. I realise that Pivot table calculated fields can be limited but I thought they could Sum values without the need of a helper column although I'm not sure that will work either. So my question is can I get this pivot table to calculate what's needed here, if not, can someone give me a formula that will solve this.

Book3
ABCDE
1DateSales
22/01/202250Row LabelsCount of Over_30
310/01/20226020221
43/03/202210Jan1
56/05/202240Mar0
618/05/202212May1
71/06/202220Jun0
89/09/202280Sep1
912/12/202290Dec1
102/02/2023520230
11Feb0
12Grand Total1
Sheet1
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi James,

The formula is =Sales>30.
Thanks for the PT calculated field link.
 
Upvote 0
Hi,
With your reference value of 30 located in cell D1, you can test following formula in cell C2
Excel Formula:
=SUMPRODUCT((MONTH($A$2:$A$10)=MONTH(A2))*(YEAR($A$2:$A$10)=YEAR(A2))*($B$2:$B$10>$D$1))

The Pivot Table performs an automatic date grouping by year, quarter, month which seems to disrupt the calculated field formula ...
 
Upvote 0
Solution
Hi,
With your reference value of 30 located in cell D1, you can test following formula in cell C2
Excel Formula:
=SUMPRODUCT((MONTH($A$2:$A$10)=MONTH(A2))*(YEAR($A$2:$A$10)=YEAR(A2))*($B$2:$B$10>$D$1))

The Pivot Table performs an automatic date grouping by year, quarter, month which seems to disrupt the calculated field formula ...
Thanks James, your formula works fine on individual cells, can it be modified so that it somehow groups the entries, in other words it returns 2 against January?
And yes it's a pity that the PT formula is disrupted, I use PTs a lot for summary/analysis.
 
Upvote 0
Hi,
In terms of grouping, the shortcut is to include this new field as a row in your Pivot Table ...
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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