Solved

Calculating the Difference Between Numbers in Consecutive Records

Posted on 2008-06-13
2
553 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now