?
Solved

Calculating the Difference Between Numbers in Consecutive Records

Posted on 2008-06-13
2
Medium Priority
?
559 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
bdreed35 earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

770 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