Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Calculate running total (horizontal way) ? 1

Status
Not open for further replies.

soushi01

Technical User
Dec 27, 2010
31
MY
Hi,

I am Newbie crystal reports user,any suggestion how to calculate running total this ?


Source Data
Customer Date Amount Tax Total Amount
A 01/01/2010 100 10 110
B 02/01/2010 150 50 200
C 03/01/2010 120 20 140
D 04/01/2010 200 100 300



Report I Expected output
Customer Date CF Total Amount Balance
A 01/01/2010 0 110 110
B 02/01/2010 110 200 310
C 03/01/2010 310 140 450
D 04/01/2010 450 300 750


thanks
 
[update]





I trying write Formula write this , however i cannot insert {@Balance} filed into the formula for CF fields because "A formula cannot refer to itsef,either directly or indirectly."


Formula For CF
//{@CF}
WhileReadingRecords;
numbervar x:=0;

IF {Sales_.Customer} = "A" THEN x:=x+0
Else if {Sales_.Customer}="B" then x:=x+( {@Balance} )
else x:=x+{@Balance} ;


Formula For Balance
//{@Balance}
{CF}+{Total Aomount}


Any Suggestion ? or My Formula is wrong ? :'(

 
Create a formula like this and place it in the detail section:

whileprintingrecords;
numbervar x := x + {table.amount}+{table.tax};

This assumes that there is one detail row per customer. If you are instead grouping on customer, then your formula should be placed in the group section and changed to:
whileprintingrecords;
numbervar x := x + sum({table.amount},{table.customer})+sum({table.tax},{table.customer});

If you want a grand total in the report footer, add a formula like this to display the results:

whileprintingrecords;
numbervar x;

-LB
 
thanks LB for the solution, I will Try it first :D
 
Sorry , LB


One of the solution that you gv me is not my expectation , becos my expectation out in Customer A 's CF display is "0", Customer no need to Group It,

what i trying to do is set Customer A in CF fild as "0", and then bring {@Balance} into the CF Field


Report I Expected output
Customer Date CF Total Amount Balance
A 01/01/2010 0 110 110
B 02/01/2010 110 200 310
C 03/01/2010 310 140 450
D 04/01/2010 450 300 750

//this part
//This assumes that there is one detail row per customer. If you are instead grouping on customer, then your formula should be placed in the group section and changed to:
whileprintingrecords;
numbervar x := x + sum({table.amount},{table.customer})+sum({table.tax},{table.customer});
 
The formula I gave you was for the balance column. Change that formula to:

//{@bal}:
whileprintingrecords;
numbervar prev;
if onfirstrecord then
prev := 0 else
prev := x;
numbervar x := x + {table.amount}+{table.tax};

Use the above formula for the balance column, and then create a display formula for the CF column:

evaluateafter ({@bal});
whileprintingrecords;
numbervar prev;

-LB
 
Hi, LB


Finally its Works !!! (handshake)

Really Thank you so much, really appreciate it [2thumbsup]


thanks

regards,
s1
 
Hi, LB

Thanks for the solution,
but sorry For disturb again, the solution that u gv me display like this ,


Customer Date CF Total Amount Balance
A 01/01/2010 0 110 110
B 02/01/2010 110 200 310
C 03/01/2010 310 140 450
D 04/01/2010 450 300 750
750


let say i want CF display Until customer "D" only, how can i Suppress CF after Customer "D" (means that don't want display CF value after Customer "D"), [ponder]




 
What report section are your fields located in? What section is this last "750" displaying in? Do you have any field suppression? Did you place the CF formula in the same section as {@bal}?

-LB
 
Hi, LB

Sorry for late reply, that issue i resolve when i add this in {@CF} field

+
Stringvar customer:={Sales_.Customer};
evaluateafter ({@@balance});
whileprintingrecords;
numbervar prev;


anyway , tq so much for the help

Regards,
s1


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top