Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Culmulative sum Post Reply Post New Topic
Author Message
shiloh
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 26
Quote shiloh Replybullet Topic: Culmulative sum
     Posted: 29 Apr 2012 at 6:06pm
Dear All,
 
I have a formula to calculate the stock bal.
 
My balstock calculation formula are as follows:
WhilePrintingRecords;
currencyVar BAL ;
 
if  {stock.TType} in ["stockout", "stockreturn"]and {productgroup} in ["A","C","P", "R","S","P1"] then
(BAL := {stock.balqty} / {stock.Conversion}) / 1000 else
if  {stock.TType} in ["stockout", "stockreturn"]and {productgroup} in ["RMS"] then
((BAL := {stock.balqty} / {stock.Conversion}) / 1200 else
BAL := {stock.balqty} / {stock.Conversion}
 
Now i want to sum all the stockbal grand total. I using running tool sum, the figure is funny.
 
Can anyone guide me how to sum out grand total. Thanks
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 30 Apr 2012 at 3:35am
I would have another variable, that would always increment, say TTLB, and don't reset it.  I am assumming that you reset BAL at some point.  If you don't, you would only need to add:
currencyVar TTLB;
 
at the end you would have
TTLB := TTLB + BAL;
BAL
 
 
then when you want to display the total, your formula would look like:
currencyVar TTLB;
TTLB
 
HTH
IP IP Logged
shiloh
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 26
Quote shiloh Replybullet Posted: 01 May 2012 at 6:44pm
I have to reset my value when reach end of each category, if without reset, the value was incorrect.

I try your formula but the result is out. The result I need is something look like as follows:
Product Code




UOM


Qty

UnitCost 
Total Cost Culmulative Cost























AG
MT
3,036.10
0.04

121,293.9630 121,293.9630
FLY
KG
805.00
0.42

336.1580 121,630.1210

Category A
Grand Total: 121,630.1210























BULK
MT
492,909.00
0.33

161,312.2827 161,312.2827
 PGE
LTR
3,497.03
0.01

22,730.6950 184,042.9777
Category B
Grand Total: 184,042.9777























RP
LTR
4,096.93
0.00

5,735.7020 5,735.7020
65B 
ROLL
11.00
288.16

3,169.8080 8,905.5100

Category C
Grand Total: 8,905.5100























RS
CUYD
4,577.88
0.03

172,033.5982 172,033.5982
SIK
LTR
2,698.44
0.00

12,400.2210 184,433.8192
 SP1
LTR
4,707.84
0.00

10,828.0320 195,261.8512

Category D
Grand Total: 195,261.8512
I still cant get this result out correctly. Can you please advice. Thanks

Regards,
Shiloh


Edited by shiloh - 01 May 2012 at 7:31pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 02 May 2012 at 3:24am
so this doesn't work?
WhilePrintingRecords;
currencyVar BAL ;
shared currencyVar TTLB;
if  {stock.TType} in ["stockout", "stockreturn"]and {productgroup} in ["A","C","P", "R","S","P1"] then
 (BAL := {stock.balqty} / {stock.Conversion}) / 1000
else
 if  {stock.TType} in ["stockout", "stockreturn"]and {productgroup} in ["RMS"] then
  ((BAL := {stock.balqty} / {stock.Conversion}) / 1200
 else
  BAL := {stock.balqty} / {stock.Conversion};
  
TTLB := TTLB + BAL;
BAL
  
 
yes you would need a reset of
shared currencyvar TTLB:=0;
 
and a display of:
shared currencyvar TTLB;
TTLB
 
are you suppressing any records?  Formulas run even if the row is suppressed.
 
otherwise, it looks like it should work.
 
IP IP Logged
shiloh
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 26
Quote shiloh Replybullet Posted: 02 May 2012 at 4:06pm
I try the formula you given, is come with error. The error is the remaining text is not part of the formula.

Not sure is the variable TTBL is cause the error




Edited by shiloh - 02 May 2012 at 4:33pm
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 03 May 2012 at 5:25am
I see unbalanced parans

WhilePrintingRecords;
currencyVar BAL ;
shared currencyVar TTLB;
if  {stock.TType} in ["stockout", "stockreturn"]and {productgroup} in ["A","C","P", "R","S","P1"] then
 (BAL := {stock.balqty} / {stock.Conversion}) / 1000
else
 if  {stock.TType} in ["stockout", "stockreturn"]and {productgroup} in ["RMS"] then
  ((BAL := {stock.balqty} / {stock.Conversion}) / 1200
 else
  BAL := {stock.balqty} / {stock.Conversion};
  
TTLB := TTLB + BAL;
BAL
IP IP Logged
shiloh
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 26
Quote shiloh Replybullet Posted: 03 May 2012 at 4:05pm
Originally posted by kevlray

I see unbalanced parans

 
shared currencyVar TTLB;
 
TTLB := TTLB + BAL;
BAL


I just add in this into my formula but error. The rest of the formula is working fine..
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