Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If statement Construction Post Reply Post New Topic
Author Message
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Topic: If statement Construction
     Posted: 17 Aug 2010 at 6:54am
Hi all
 
 
I was wondering if someone could please help me with an IF Statement construction. I need to count the instances where the amount in Table A is greater than 3.5 and less than 4 but they also need to be equal to the Table B values of 39 or 46 or 93 or 95. (just one of these values)Smile
 
 
I have joined an ID in TableA to an ID in Table B as an equal join.
 
 
Something tells me that my if statements is written incorrectly and I was wondering if anyone could please help me to correct  it.
 
I am using crystal syntax and I am pretty new at this.
 
 
 
 
Global NumberVar PlusThreeFivePushBike;
 
 
If {TableA.adlg_drv_units} > 3.5 and {TableA.adlg_drv_units} < 4 or  {TableB.adck_tariff} = "39" or {TableB.adck_tariff} = "46" or {TableB.adck_tariff} = "93" or {TableB.adck_tariff} = "95" then

 PlusThreeFivePushBike := PlusThreeFivePushBike +1

 
Thanks
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 17 Aug 2010 at 7:38am
Try:
 
Global numbervar PlusThreeFivePushBike:=PlusThreeFivePushBike +
(if ({TableA.adlg_drv_units} > 3.5 and {TableA.adlg_drv_units} < 4)
and
({TableB.adck_tariff} = "39"
or {TableB.adck_tariff} = "46"
or {TableB.adck_tariff} = "93"
or {TableB.adck_tariff} = "95")
     then 1
          else 0);
 
PlusThreeFivePushBike;
 
|< /\ '][' ( )
IP IP Logged
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Posted: 18 Aug 2010 at 12:15am
Thanks for that it seems to work. except for when i set the values as greater than 4 , and again at less than two. I then get a zero value return on those.
 
For the  < 2 values I have tried making it ' >0 and <2' but i still get  a zero.
 
Much appreciated.   
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 18 Aug 2010 at 2:06am
Why are you trying to get a count if it's less than 2 or grater than 4? I thought you only needed the count to be if it was between 3.5 and 4 AND equal to one of the other values in table B. Should it be between 3.5 and 4 OR one of the values in table B?
|< /\ '][' ( )
IP IP Logged
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Posted: 18 Aug 2010 at 2:22am

I need to have the Total amount from the overall count (which was calcluated in a  different count formula)  split into :

greater than four km
betweeen 3.5 and 4 km
between 3 and 3.5
between 2.5 and 3
between 2 and 2.5
and less than two
 
For formula worked for the four middle criteria but not the 1st and last.
 
 
and they all need to contain one of  the values : '39'  '46'  '93'  '95' from tableB.  
 
Thanks for help here
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 18 Aug 2010 at 2:45am
Hmmm...seems strange that it wouldn't work. Do you need to be including the outter bounds?
 
>=0 and <=2
|< /\ '][' ( )
IP IP Logged
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Posted: 19 Aug 2010 at 4:02am
Just wanted to say thanks again. Its working now.
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