Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Consolidation (n00b) Post Reply Post New Topic
Author Message
walkitinkid
Newbie
Newbie


Joined: 16 Jun 2011
Online Status: Offline
Posts: 16
Quote walkitinkid Replybullet Topic: Formula Consolidation (n00b)
     Posted: 16 Jun 2011 at 10:30am
Hi all,
 
I have 4 formula's I would like to get the total of
 
1.
numberVar callcnt := 0;
callcnt := if {ado.EventType} = "Call" and {ado.was_FirstContact} = -1
then callcnt+1 else callcnt;
 
2.
numberVar walkIncnt := 0;
walkIncnt := if {ado.EventType} = "Walk-In" and {ado.was_FirstContact} = -1
then walkIncnt+1 else walkIncnt;
 
3.
numberVar emailcnt := 0;
emailcnt := if {ado.EventType} = "Email" and {ado.was_FirstContact} = -1
then emailcnt+1 else emailcnt;
 
4.
numberVar othercnt := 0;
othercnt := if {ado.EventType} = "Other" and {ado.was_FirstContact} = -1
then othercnt+1 else othercnt;
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 Jun 2011 at 11:31am
drop the :=0, it resets the formula to 0 everytime you run it.
 
typically I have a 'reset' formula that is in the group header like:
numbervar callcnt:=0;
numbervar walkIncnt :=0;
...
 
 
HTH
IP IP Logged
walkitinkid
Newbie
Newbie


Joined: 16 Jun 2011
Online Status: Offline
Posts: 16
Quote walkitinkid Replybullet Posted: 16 Jun 2011 at 11:58am
Thanks locke,
 
It occured to me that I may have worded my posting wrong, what I'm looking to do is consolidate my formula so that I get a total for all four of those variables.
 
ie. count how many times "walk-in" "call" "other" and "email" occur and get a grand total.
 
I tried
 
numberVar totalcnt := 0;
callcnt := if {ado.EventType} = "call" or "walk-in" or "email" or "other" and {ado.was_FirstContact} = -1
then totalcnt+1 else totalcnt;
 
and that doesnt work. I get an error.


Edited by walkitinkid - 16 Jun 2011 at 12:03pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 Jun 2011 at 12:30pm
if ({ado.EventType} = "Call" and {ado.was_FirstContact} = -1) or ({ado.EventType} = "Walk-In" and {ado.was_FirstContact} = -1) or ({ado.EventType} = "Email" and {ado.was_FirstContact} = -1) or ({ado.EventType} = "Other" and {ado.was_FirstContact} = -1) then
then totalcnt+1 else totalcnt;
 
 
or
 
numbervar w;
numbervar x;
numbervar y;
numbervar z;
w+x+y+z
 
HTH
 
IP IP Logged
walkitinkid
Newbie
Newbie


Joined: 16 Jun 2011
Online Status: Offline
Posts: 16
Quote walkitinkid Replybullet Posted: 16 Jun 2011 at 1:01pm
THANKS THAT WORKED!
 
one more teeny tiny problem. there are two trailing 0's for that number on the report. how do I suppress those? nothing I do in "Format Field" seems to work
IP IP Logged
walkitinkid
Newbie
Newbie


Joined: 16 Jun 2011
Online Status: Offline
Posts: 16
Quote walkitinkid Replybullet Posted: 16 Jun 2011 at 1:22pm
solved, Insted of right clicking on the field, I used the field explorer, THANKS A TON
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