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

cumulative totals 1

Status
Not open for further replies.

LouiseR

MIS
Nov 18, 2003
17
GB
Hi

I am trying to calculate a running total that resets if a criteria is not met, i.e

if the next value of a field is the same as the current one, then add one to a total, if the value is not the same, then reset the total to zero.

Can anyone help?

Thanks,
Louise.
 
P.S. This is what I have tried so far..

local numbervar total:=1;


if ({CallLog.Application}= Next ({CallLog.Application})and {CallLog.Cause} =Next ({CallLog.Cause}))

then total:= total+ 1

else if ({CallLog.Application}<> Next ({CallLog.Application})and {CallLog.Cause} <>Next ({CallLog.Cause}))

then total:= 0;


total;
 
Try this :

WhilePrintingRecords;
Local NumberVar Total;
If {CallLog.Application} = Previous({CallLog.Application}) then Total := Total +1 else Total := 1;
Total;

Reebo
UK

&quot;Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.&quot;
- Albert Einstein (1879-1955)
 
Hi again

I don't think I've explained myself properly:

if the next record is the same as the current one, total=1, if the next one is the same again total =2, etc.

Then, if the next record is not the same as the previous, total = 0.

The formula given, just gives a series of 1s.

Thanks again
Louise.
 
Sorry, I was answering another post very similar at the same time, try:

WhilePrintingRecords;
Local NumberVar Total;
If {CallLog.Application} = Next({CallLog.Application}) and
{CallLog.Cause} = Next({CallLog.Cause}) then Total := Total +1 else Total := 0;
Total;



Reebo
UK

&quot;Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.&quot;
- Albert Einstein (1879-1955)
 
Hello

Here'a wee example of what I am looking for, formula column is the result of the formula you gave, req'd is what I would like to be held in the total:

Cause Application formula req'd

Program error Anti-Virus 1.00 1.00
Program error Anti-Virus 1.00 2.00
Program error Anti-Virus 0.00 3.00
Program error Apps 1.00 1.00
Program error Apps 0.00 2.00
Backup required Apps 1.00 1.00

Thanks for your preseverance!

Louise.








 
What I ultimately want to do is get a top 10 of cause and application together based on the formula, eg Program Antivirus has 3 entries then Program error Apps has 2 entries etc.

Thanks very much
Louise.
 
There is a Top N report in Crystal if that's what you want.

What you want is a Running Total filed (not a formula), using a Count to accomplish the above.

Group your rows by Cause and Application, and have the Running Total reset at the Application level and place the RT in the group footer.

Use an evaluate->Use a Formula in the RT for your criteria, as in:

{CallLog.Application} = Next({CallLog.Application}) and
{CallLog.Cause} = Next({CallLog.Cause})

-k
 
Hi synapsevampire

I have tried this, but the group n function does not seem to work with running totals- the icon is greyed out and the running total does not appear in the drop down list.

Also, do you mean to have 2 groups, the first on Cause and the second on application?

Thanks
Louise.
 
Sorry, I meant Top N.

The group sort expert item is greyed out from the report menu as is the icon.

Louise.
 
You could concatenate the two fields as in {@concat}:

{table.cause} + &quot; &quot; + {table.application}

Group on this formula and then insert a summary (count) at the group level. Then go to topN and choose &quot;count of {@concat} as your topN field with N = 10.

-LB
 
Thanks very much lbass! Worked a treat- I'll remember that trick!

Louise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top