adding a calculated field to a pivot table

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,397
Office Version
  1. 2007
I have a pivot table to which I'm trying to add a calculated field but having no luck.

I am trying to check the difference between 2 numeric fields and depending on whether or not if it is positive or negative I want to display 'over' or 'under'.

I can get it to accept the formula =column1-column2 but when I try to add an IF statement such as this:

=IF(column1-column2>0,"OVER","UNDER")

then excel wont accept it. Is there any way I can achieve this?

tia
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
What if you make the formula column1 - column2
and then custom format it with
"over";"under"
 
Upvote 0
Hi fazza. Do you mean Conditional formatting? Can you do that with text?
 
Upvote 0
hi, merlin

Not conditional formatting. A custom format.
So go to normal numbers formatting (CTRL-1 then N). there is a list of categories on the LHS. Last one is custom. Near middle of dialog at type enter, for example "positive";"negative"

OK?
 
Upvote 0
Wow - never knew it could do that! What's the convention for this? Does it just accept 2 strings and apply the first to positive values and the second to negative?

It gets be in the ball park but I needed a more complex formula to take into account values which are almost the same e.g. a value might be within 5% of the other but still negative so I would ignore it. I know I can do that with IFs. If I can't pull that off I'll go with the custom formatting as you suggest.
 
Upvote 0
It's a nifty little thing and I'll be using it again!

I cracked my problem by adding a column to my table and inserting 2 columns/formula into my pivot table. I did a bit of maths to give me either a positive result or a negative one and then using this number formatting. Not elegant but it works....

Thanks for all the help.
 
Upvote 0

Forum statistics

Threads
1,215,963
Messages
6,127,951
Members
449,412
Latest member
montand

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