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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running total reset

Status
Not open for further replies.

zenmind

MIS
May 9, 2010
10
0
0
US
Is there a way to reset running totals incrementally? If several transactions for the same person total or exceed $10,000, it's simple to do a running total but if I need to reset the running total to 0 for that same person after the first $10,000 is received and arrive at a second running total exceeding $10,000, how is a reset achieved to calculate this second cumulative amount? In the end, I'm trying to show the date and amount that any cumulative amounts of $10,000 were received. Any advice is appreciated. Crystal Reports XI, Oracle db.
 
Try this:

//{@accum}:
whileprintingrecords;
numbervar x;
numbervar y;
datevar z;
if x <= 10000 then (
x := x + {table.amount};
z := date(0,0,0)
);
if x > 10000 then (
y := y + 1;
x := x-10000;
z := {table.date}
);
x

Create a second formula to display the date when $10,000 has been achieved:

evaluateafter({@accum});
whileprintingrecords;
datevar z;

If your amount field is a currency, change "numbervar" to "currencyvar" in all places.

This formula will return the current cumulative total until the record where the total exceeds 10,000. On that record, the balance of the cumulative total minus 10,000 will be displayed, and the accumulation will continue. Not sure what exactly you wanted to display on that record. The date field will indicate that that record was the one where 10000 was reached, like this:

Amt Cum Date
6500 6500
3000 9500
4000 3500 1/16/2012
5000 8500
6000 4500 2/12/2012
7000 1500 2/13/2012
4000 5500

//etc.

You could add a another formula that just displays 10000, by using a formula like this:

evaluateafter ({@accum});
whileprintingrecords;
datevar z;
if z <> date(0,0,0) then
10000 else
0

Then suppress this if zero.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top