Solved

Calculating the Difference Between Numbers in Consecutive Records

Posted on 2008-06-13
2
554 Views
Last Modified: 2010-08-05
I have a report with data similar to this format:

Customer       Mileage
500                 1000
500                 2000
500                 2200
500                 2500

What need help doing is calculating the difference between the mileages, so it would look like this:

Customer       Mileage        Difference
500                 1000              0                 (since there is nothing to subtract from)
500                 2000              1000            (2000 - 1000)    
500                 2200              200               (2200 - 2000)
500                 2500              300               (2500 - 2200)

I can't seem to figure out how to get that difference to calculate.

Thank you for your help!

0
Comment
Question by:leesmithinc
2 Comments
 
LVL 28

Accepted Solution

by:
bdreed35 earned 500 total points
ID: 21780999
You can write a formula like this to get the difference:

whileprintingrecords;
if not onfirstrecord
then {table.mileage} - previous({table.mileage})
else 0
0
 

Author Closing Comment

by:leesmithinc
ID: 31467001
That worked great.  Thanks!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question