Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Counting dependent on datediff Post Reply Post New Topic
Author Message
Baxters80
Newbie
Newbie
Avatar

Joined: 04 Mar 2009
Location: United States
Online Status: Offline
Posts: 4
Quote Baxters80 Replybullet Topic: Counting dependent on datediff
     Posted: 04 Mar 2009 at 9:07pm
I need to count unique values of Col A dependent upon the date difference of two dates. If datediff is <12 months then count....
“Somewhere, something incredible is waiting to be known.”
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Mar 2009 at 5:58am
You can use a running total as a DistinctCount on column A with a formula on the evaluate. Not sure for the rest option because you don't mention grouping
The evaluate formula will be your datediff("M",date1,date2)<12
IP IP Logged
Baxters80
Newbie
Newbie
Avatar

Joined: 04 Mar 2009
Location: United States
Online Status: Offline
Posts: 4
Quote Baxters80 Replybullet Posted: 05 Mar 2009 at 7:09am
Thank you for your quick response. I am currently using the datediff as you stated. The grouping will be on Column A,
“Somewhere, something incredible is waiting to be known.”
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Mar 2009 at 7:42am
if you want a Distinct Count for all records in the report then use a Ruuning total
CAll it something like "ColADistinctCount"
Field to Summarize=Column A
Type= Distinct Count
Evaulate- USe a formula 'datediff("M",date1,date2)<12'
Reset as: Never
 
Place this Running Total Field in your Report Footer to get your number.
Running Totals only work in Details or Footers and it muse be placed in a section that can evaulate everything it needs to.
Also, you can make a formula field with your date diff and temporarily drop it in your detail row to make sure it is giving you the correct data. If you invert the dates you will get a negative number and all of your records would then be <12 and give you some false positives.
Create a Formula field as "MonthTest" and insert this formula:
'datediff("M",table.date1,table.date2)'
Place it on your details row and see if you are getting the correct month difference. If it is giving you all negative values you need to switch the order of the date fields
'datediff("M",table.date2,table.date1)'.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum