Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: YTD and MTD totals Post Reply Post New Topic
Author Message
CrystalKiwi
Newbie
Newbie
Avatar

Joined: 08 Jun 2009
Location: New Zealand
Online Status: Offline
Posts: 3
Quote CrystalKiwi Replybullet Topic: YTD and MTD totals
    Posted: 08 Jun 2009 at 9:58pm
I am wanting to have running totals for MTD and YTD totals in the same report , can anyone advise the easiest way to do this ?
 
Tongue
Kiwi
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 09 Jun 2009 at 6:33am
DBlank would probably say running totals, but alas, that is not my forte.
 
I would say shared variables. You would want to set them zero, at some point.  Obviously MTD would be when the month changes, and YTD at the year change.  You would want to display them in a footer, probably for month and year.  These are pretty easy formulas:
shared numbervar MTD :=0;
shared numbervar YTD :=0;
""  //this sets to 0...remove the :=0 and just one at a time to display the values....you don't have to do both at the same time (and wouldn't want to, this just shows syntax)
 
But how do we increment the values.  A formula that would be dropped in the details section, could make it really simple, like:
shared numbervar MTD := MTD +{table.field};
shared numbervar YTD := YTD +{table.field};
"" //this just hides the results of the formula
 
HTH
IP IP Logged
BrianL
Newbie
Newbie


Joined: 16 Feb 2009
Location: United States
Online Status: Offline
Posts: 6
Quote BrianL Replybullet Posted: 09 Jun 2009 at 8:31am

To set these up using Running Totals you can "Evaluate by Formula" and use something like this for MTD:

Month({datefield}) = Month(CurrentDate) and
Year({datefield}) = Year(CurrentDate)
 
 
and for YTD evaluate by
 
Year({datefield}) = Year(CurrentDate)
 
 
Reset as appropriate, should be good to go.
 
Hope this helps,
Brian


Edited by BrianL - 09 Jun 2009 at 8:33am
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.018 seconds.