Print Page | Close Window

How to calculate balance brought forward

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9029
Printed Date: 03 May 2024 at 12:40pm


Topic: How to calculate balance brought forward
Posted By: Vishakha
Subject: How to calculate balance brought forward
Date Posted: 03 Feb 2010 at 6:46am
I have to create statement report with debit credit and balance from parameter date say 01/10/2009. for balance i am using below formula
 
shared numberVar rbalance;
IF OnFirstRecord THEN
rbalance := 0 + mailto:%7B@debit - {@debit } - mailto:%7B@credit - {@credit }
ELSE
rbalance := rbalance + mailto:%7B@debit - {@debit } - mailto:%7B@credit - {@credit } ;
 
Now how should i calculate balance brought forward , that is total(rbalance) of all dates before 01/01/2009 and add this balance as opening balance in above formula instead of 0.
Please help me,



Replies:
Posted By: lockwelle
Date Posted: 03 Feb 2010 at 11:14am
you would need to know the balance brought forward.  If you are not using a stored proc or view, the best option would be to create a subreport (I hate to say that, as the performance suffers) and calculate the balance and then returned via a shared variable.
 
HTH


Posted By: Vishakha
Date Posted: 04 Feb 2010 at 9:55am
Hi
Thanks Lockwelle for your reply.
 
I am not able to get balance from subreport to main report. it is 0 Please help me.
 
I created subreport and balance is calculated in subreport i am writing below formula in detail section
 
shared numberVar rbalance1;
IF OnFirstRecord THEN
rbalance1 := 0 + mailto:%7b@debit - {@debit } - mailto:%7b@dbcd - {@dbcd }
ELSE
rbalance1 := rbalance1 + mailto:%7b@debit - {@debit } - mailto:%7b@dbcd - {@dbcd } ;
 
in Main report - subreport is in Page header and not suppressed
Formula in main report for balance in detail section
 
shared numberVar rbalance;
shared numberVar rbalance1 := 0;
IF OnFirstRecord THEN
rbalance := rbalance1 + mailto:%7b@debit - {@debit } - mailto:%7b@dbcd - {@dbcd }
ELSE
rbalance := rbalance + mailto:%7b@debit - {@debit } - mailto:%7b@dbcd - {@dbcd }


Posted By: lockwelle
Date Posted: 05 Feb 2010 at 6:27am
well, you are setting rbalance1 to 0, so it is going to be 0.  try creating a formula that just displays the shared variable, just to see if it is getting to the report.



Print Page | Close Window