Adding a calculated field to a pivot table is not giving me the results that I think it should.

OodaLoop

New Member
Joined
Feb 16, 2013
Messages
6
Hello everyone.

I have a pivot table that has two columns that contain dates.

I am trying to add a column with a OR formula that returns true or false base on whether the first date is equal to the second date OR the first date +1 equals the second date.

The formuala I use is

=OR(FirstDate=SecondDate,FirstDate+1=SecondDate)

But my result looks like this:

12/12/20121/4/20130
9/28/20129/28/20130

<tbody>
</tbody>

When I create a column manually that isn't part of the Pivot Table it works, but when I add a calculated field for the pivot table I get that.

The field is formatted as General. When I change it to short date I just get 1/0/1900.

Thoughts on what is going on here?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Are FirstDate and SecondDate data fields or row fields in the pivot table?

Generally speaking, data fields have some function performed on them. Because of this, calculated fields often do not do what you think they will.

What you probably want to do is add the column "IsCurrent" to the data table you are using to make the pivot table and put your formula in there.
 
Upvote 0
You said that this is a pivot table.

Is it just a table and not a pivot table?

Did I misunderstand?


A pivot table is often used to summarize information from a table.
 
Upvote 0
I can not reproduce your problem (Excel 2007)

The formula below worked for me (Calculated Field)
=OR(Date1=Date2-1,Date1 =Date2 )

Dates as dd/mm/yyyy

NameDate1Date2Compare
John10/01/201314/01/20130
11/01/201312/01/20131
Mary12/01/201312/01/20131
13/01/201314/01/20131

<colgroup><col style="width: 94pt; mso-width-source: userset; mso-width-alt: 4571;" width="125"> <col style="width: 83pt; mso-width-source: userset; mso-width-alt: 4022;" width="110"> <col style="width: 78pt; mso-width-source: userset; mso-width-alt: 3803;" width="104"> <col style="width: 59pt; mso-width-source: userset; mso-width-alt: 2889;" width="79"> <tbody>
</tbody>

Column Compare (calc field) formatted as Number no decimal places

M.
 
Upvote 0
OK so you have a table like:

StartDateEndDateOtherData
12/12/20121/4/20132,133
9/28/20129/28/201362,123

<tbody>
</tbody>

what you want is

FirstDateSecondDateOtherDataisCurrent
12/12/20121/4/20132,1330
9/28/20129/28/201362,1231

<tbody>
</tbody>



under iscurrent, put in the formula:

=if(or([@FirstDate]=[@SecondDate],[@FirstDate]+1=[@SecondDate]),1,0)

You were pretty close originally.
 
Upvote 0

Forum statistics

Threads
1,215,401
Messages
6,124,705
Members
449,182
Latest member
mrlanc20

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