Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Countup / Countdown on Text Post Reply Post New Topic
Author Message
justjon
Newbie
Newbie


Joined: 05 Mar 2009
Online Status: Offline
Posts: 10
Quote justjon Replybullet Topic: Countup / Countdown on Text
     Posted: 03 Mar 2010 at 12:32am
Hi All,

I am desperately in need of a formula that will start at "0" but then count up/down when specific lines of texts display in a report.

For instance, it would start at 0 - but when it see's "has logged on." it would go to 1, then 2, and so on.

But when it see's "has logged off." I would want it to count back down.

This would be VERY handy for me.

Thanks,
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 03 Mar 2010 at 5:16am

Do a manual running total. Create an Initialize formula:

global numbervar nCount:=0;
 
Put this in the Report Header if it will never restart, or in a Group Header if you want it to restart at 0 when it hits a new group.
 
Then create the Calculation formula:
 
global numbervar nCount:=nCount + (if {table.field} = 'has logged on' then 1
     else if {table.field} = 'has logged off' then -1
     else 0);
 
nCount;
 
Depending on the field you may have to do a if 'has logged on' in {table.field} or something along those lines.
 
If you want to display the number you need a Display formula:
 
global numbervar nCount;
 
Hope that helps.
 
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum