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

Creating Running Total for a formula 1

Status
Not open for further replies.
Dec 18, 2006
69
US
Hi all,

I am currently on Crystal XI professional. I created a formula that uses the PREVIOUS command to get my numbers showing correctly in the detail section. They are listed like this:

100
25
15
250
20
10

I need to do running total for 100, 25 and 15 and then when it hits line 250, I need to start over and do running total for 250, 20 and 10. I do have to tell you that there's a transaction type called AP for the 250 line. So basically if the transaction type is AP then it needs to start over in doing the running total until it hits another transaction AP or the report finishes.
The first line of the report does not have the AP transaction type. So in summary, it needs to start the running total from the 1st line of the report until it hits an AP trans type and then it should start from 0 again and do the running total.

The report is sorted by transaction date in descending order. So I am not sure how, if need to, that I can even do group or anything.

I hope I explained this clearly. Thanks in advance.
 
Please show the content of your formula that returns the numbers you show above. Also, please add the transaction type field to your sample data.

-LB
 
Okay -
I will try my best to get this in order. There are so many formula on here; they give me headaches just by looking at them.

Trans Type Calculation
PROP 408.86
PROP 4.29
PROP 8.58
PROP 0.71
AP 243.94
PROP 14.03
PROP 0.41

Calculation is
current_cost - value_change

current_cost is
IF {#Count} = 1 THEN {inv.average_cost} * {inv.on_hand}
ELSE IF {#Count} > 1 AND {tran.trans_type} = 'AP' THEN {@OnHandB4} * {tran.unit_cost} ELSE 0

I hope this is enough information.

Thanks again.
 
I forgot to tell you that I need to do running total from line 1 through line 4 and then line 5 (AP) starts with that number and do the running total all over again. All of this information is in the detail section.
 
Do you have any suppressed records?

If you don't have suppressed records or if the value of {@yourformula} is 0 for all suppressed records, the following formula should work:

whileprintingrecords;
numbervar x;
if {table.transtype} = "APO" then
x := 0;
x := x + {@yourformula};

-LB
 
Holy smokes,

lbass - that is it. I knew about the whileprintingrecords formula but I didn't know about the ability for one to use an if then statement.

You saved me :)

Thank you so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top