Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: keepinga running total in a formula? Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: keepinga running total in a formula?
     Posted: 14 Nov 2012 at 3:51am
Hi,

Not  sure if the title really desc. what I need..
But here it goes..
I have a report the groups on name then location.
a name can have up to 4 locations
i hvae a counter on location
so I have abc  counter =1
                def  counter=2 etc...
at the break of client
I want to display up to 4 locations

client1  - abd,def
client2  - abc,def,ghi
client3  - abc,ghi
client4 - abc,def,ghi,jkl 

Does this make any sense??

Thanks
Joe

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 14 Nov 2012 at 6:43am
sure, since you already have the counters, you just need to format them...I'm thinking something like:
 
shared numbervar abc;
shared numbervar def;
shared numbervar ghi;
shared numbervar jkl;
local stringvar s := "";
 
if abc <> 0 then s := s + ", " + totext(abc,0,"");
if def <> 0 then s := s + ", " + totext(abc,0,"");
if ghi <> 0 then s := s + ", " + totext(abc,0,"");
if jkl<> 0 then s := s + ", " + totext(abc,0,"");
 
mid(s,3)  //trim the leading ', '
 
of course you can change the flag to hide/show to whatever is appropriate.
 
HTH
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 29 Nov 2012 at 11:22am
Sorry ,

I'm just getting back to this..
Sorry I'm a bit confused...
I have string variables:
ABC
DEF
GHI
JKL

each one moves an 'X" to  them if it meets a critera...


a client can have from 1 to all 4
at the end I want to have a count of who has only 1
who has two,
3 and
4 ...
                                name            abc  def  ghi   jkl
details looks like ...  jim                  X            X     X
                                Joe                        X      X      

Footer looks like
21 have only 1
32 have 2
etc

Thanks
Again



Edited by jbalbo - 29 Nov 2012 at 11:42am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 29 Nov 2012 at 12:05pm
sorry, misunderstood.
 
perhaps something like:
shared numbervar one;
shared numbervar two;
shared numbervar three;
shared numbervar four;
local numbervar i;
 
if {table.abc} = 1 then i := i +1;
if {table.def} = 1 then i := i +1;
if {table.ghi} = 1 then i := i +1;
if {table.jkl} = 1 then i := i +1;
 
if i = 1 then one := one + 1;
if i = 1 then two := two + 1;
if i = 1 then three := three + 1;
if i = 1 then four := four + 1;
 
"" //hide the output
 
hopefully it is closer, or least points in a useful direction
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 29 Nov 2012 at 12:18pm
Thanks for getting bacj..

My fault..
Im horrid at explaining..

Abc..def... etc are running totals created via a formula
what I do as unconventional as it sounds.. I use a formula with the letter X in it then in the running total if a value meets a criteria it puts the X in the running total

Not sure how to set up the shared variables as u explained?

Thanks Again


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 30 Nov 2012 at 5:20am
I'm not sure exactly how things look, but does this make more sense?
 
shared numbervar one;
shared numbervar two;
shared numbervar three;
shared numbervar four;
shared numbervar abc;
shared numbervar def;
shared numbervar ghi;
shared numbervar jkl;
local numbervar i;
if abc > 0 then i := i +1;
if def > 0 then i := i +1;
if ghi > 0 then i := i +1;
if jkl > 0  then i := i +1;
if i = 1 then one := one + 1;
if i = 2 then two := two + 1;
if i = 3 then three := three + 1;
if i = 4 then four := four + 1;
 
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 03 Dec 2012 at 11:34am
I think this will work but do I setup as seperate formulas?

Thanks

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 05 Dec 2012 at 5:03am
you would only need separate formulas for the display, I believe..you will figure it out during design I'm sure.
 
you will need 1 in the details section to increment, and one in header to reset...but I think you knew that already
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