Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Calculating Mileage based on dates. Post Reply Post New Topic
Author Message
Tomsss
Newbie
Newbie


Joined: 02 Jul 2009
Location: Canada
Online Status: Offline
Posts: 20
Quote Tomsss Replybullet Topic: Calculating Mileage based on dates.
    Posted: 05 Jan 2010 at 7:12am
I have a table that has a date field and a mileage number.
 
For example it might read:
 
Jan 01    10000
Feb 01    12000
Mar 01    16000
etc.
 
I need to be able to calculate the current month as well as the YTD numbers. So on Mar 1st I would calculate 4,000 for the month and 6,000 for the year.
 
Just to make it more difficult there may not be a reading every month. It seems like I should be able to do it but in ten years of working with Crystal I have never come across this before and am stumped.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 Jan 2010 at 7:11am
I would think a formula with variables should do it.  If a reading is missing, that shouldn't affect a formula, while a null value would have to be accounted for, otherwise, it is just a couple of counters.
 
I would think something like...
shared numbervar lm;  //last month
shared numbervar ytd;
local numbervar tm;  //this month
 
tm := {table.field} - lm;
ytd := ytd + tm;
 
tm
 
HTH
 
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.047 seconds.