• Status: Solved
• Priority: Medium
• Security: Public
• Views: 571

# Calculating the Difference Between Numbers in Consecutive Records

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.

0
leesmithinc
1 Solution

Commented:
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 Commented:
That worked great.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.