Excel Pivot-Table calculated fields with if statement return wrong results

John2009

New Member
Joined
Sep 28, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello All,

I'm new to this nice forum and have the following question/problem. I hope someone could help.

In a simple Excel Pivot table the calculated fields return wrong values. Tested on Excel 2007 and Excel 365.

For comparing purposes I've added the columns Analysis and Develpement with IF statment in the Excel table.

What I would expect is that it should be Analysis = CFAnalysis and Develpement = CFDevelpement.

Do you have any ideas why the calculated fields behave like this?

Thanks
John
 

Attachments

  • Excel Pivot-Table calculated Fields with wrong results.png
    Excel Pivot-Table calculated Fields with wrong results.png
    40.5 KB · Views: 8

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
The values are actually correct given how calculated fields work, which is at the aggregate level. They always SUM any fields you use in the formulas before they do anything else. So your first formula is effectively:
=IF(SUM(Type)=1;SUM(Hours);0)
 
Upvote 0
The values are actually correct given how calculated fields work, which is at the aggregate level. They always SUM any fields you use in the formulas before they do anything else. So your first formula is effectively:
=IF(SUM(Type)=1;SUM(Hours);0)
Hi Rory,
thanks for your answer. I'm not sure, if it is so as you describe. There are some examples on the internet, which show calculated fields working the way I would expect. For instance
Excel: Use IF Statement in Pivot Table Calculated Field
I can't figure out, where the difference between my approach and the one in the above link is.

If calculated fields work really like you describe, I don't find it usefull. In my openion the aggregation should work on each level.

John
 
Upvote 0
You should read that linked article again, paying attention to the helper column. That is required so that the sum of the helper column is either 0 or non-zero, and that allows you to distinguish between the types.
Calculated fields work exactly as I described, whether you find that useful or not. ;)

If you are working with 365, you can use the data model and power pivot where you can create measures that can do just about anything you can think of. For 2007, you will be stuck with using helper columns in your source data.
 
Upvote 0

Forum statistics

Threads
1,221,899
Messages
6,162,686
Members
451,782
Latest member
LizN

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