Monday, March 26, 2012

running total of differences in Crystal Reports

Hi everyone. I need help writing a function in Crystal Reports. I need a running total of the difference of two columns. I know the starting value and I need something like:

Net := Start + (SubCol - AddCol)

in a loop I guess.

So, if the starting number is 20, the report should look somewhat like:
(Its always adding the difference to the previous net value)

Field1 Field2 Add Sub Net
------------
12 A+ 10 10 '20 + (0-10) = 10
13 A 5 25 '10 + (5 - 0) = 15
11 C 12 37 '15 + (0 - 12) = 3
01 D 10 27 ' 3 + (10 - 0) = 13
12 B 11 38 '13 + (0 - 11) = 2Why don't you try creating new formula for each runnig total, add a group, copy all fields from detail into group, hide detail and do the difference after using the running total formulas??

Field1 field2 field3
1 1 1
3 4 6
--------------------
detail rt1 rt2 rt3
--------------------
group rt1-rt2

Rob

Hi everyone. I need help writing a function in Crystal Reports. I need a running total of the difference of two columns. I know the starting value and I need something like:

Net := Start + (SubCol - AddCol)

in a loop I guess.

So, if the starting number is 20, the report should look somewhat like:
(Its always adding the difference to the previous net value)

Field1 Field2 Add Sub Net
------------
12 A+ 10 10 '20 + (0-10) = 10
13 A 5 25 '10 + (5 - 0) = 15
11 C 12 37 '15 + (0 - 12) = 3
01 D 10 27 ' 3 + (10 - 0) = 13
12 B 11 38 '13 + (0 - 11) = 2|||Hi Rob. Thanks for the response. I finally got it to work by declaring a Shared variable and putting it in the report header. Global wouldn't work for some reason. Then, using that variable, I used the same function:

Shared Numbervar x;
x := x + ({Col.Sub} - {Col.Add})

and put it in the details section. Seems to work!

No comments:

Post a Comment