Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Help in formula to calculate next record Post Reply Post New Topic
Author Message
waely
Newbie
Newbie


Joined: 20 May 2009
Online Status: Offline
Posts: 8
Quote waely Replybullet Topic: Help in formula to calculate next record
     Posted: 18 Oct 2010 at 11:15am
Hi,
here is a sample data
 
             ID          Total      Completed   
            -----      -----------    ------------
1 367     0
2 364 12
3 346 2
4 341 6
5 331 6
6 324 5
7 319 2
8 317 3
9 313 28
10 278 28
11 241 7
 
I need to create a formula (@actual) that skips the first record then subtract NEXT Record completed from total.
example:
the first record is 367
second record is 367 - 12 = 355
third record is     355 - 2   = 352
etc... see results below...
 
 
             ID         Total         Comp    Acutal
              ---        -----------    -------    ---------
1 367     0 367
2 364 12 355
3 346 2 353
4 341 6 347
5 331 6 341
6 324 5 336
7 319 2 334
8 317 3 331
9 313 28 303
10 278 28 275
11 241 7 268
 
I started this formula but it's not working:
 
local NumberVar x;
x:= {command.Running_Total};
if RecordNumber = 1 then x
else x := x - next({command.COMPLETED_COUNT})
 
am I close to the correct formula?
 
thank you for your help
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 Oct 2010 at 3:19am
real close...shared or global for the variable, local will discard the value as soon as it done with the formula, but for a running total like this, you want it to persist.
 
HTH
IP IP Logged
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