Print Page | Close Window

YTD and MTD totals

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6629
Printed Date: 09 May 2024 at 2:42pm


Topic: YTD and MTD totals
Posted By: CrystalKiwi
Subject: YTD and MTD totals
Date 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



Replies:
Posted By: lockwelle
Date 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


Posted By: BrianL
Date 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



Print Page | Close Window