Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Is Statement help Post Reply Post New Topic
Author Message
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Topic: Is Statement help
     Posted: 23 Aug 2010 at 4:53am
Hi Guys
 
 
I am attempting to construct an if statement that will enable me to count all jobs between certain central London postcodes. The statement i have written is:
 
Global NumberVar EC1EC1 := EC1EC1+
(If ((Left({TableA.adad_postalcode},3) ="EC1") and {TableA.adad_addressnumber} = 0 )
and
    ((Left({TableA.adad_postalcode},3) ="EC2") and {TableA.adad_addressnumber} =1)

      then 1
             else 0);
 
If i only use the first line of the if statement it works fine. If i run
both lines then my result is 0 . I have a feeling that my brackets may not be right but i am not so sure.
 
 
 The numbers means 1=collection 0= delivery.
 
I need to work out all collections from ec1 to ec1
                                                            ec1 to ec2
                                                            ec1 to ec3 etc.
 
EC1/2/3 are London postcode.
 
Any help would be appreciated.
 
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 23 Aug 2010 at 5:50am

Maybe instead of AND use OR between the EC1 and EC2 conditions. Depends on what you want though. You could also try:

 
Global NumberVar EC1EC1 := EC1EC1+
(If ((Left({TableA.adad_postalcode},3) ="EC1") or(Left({TableA.adad_postalcode},3) ="EC2"))
and
    (({TableA.adad_addressnumber} = 0 ) or {TableA.adad_addressnumber} =1))

      then 1
             else 0);


Edited by FrnhtGLI - 23 Aug 2010 at 5:52am
|< /\ '][' ( )
IP IP Logged
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Posted: 23 Aug 2010 at 6:29am
I have tried this but i am getting a higher number than expected:
 
I basically need to calculate all jobs between london EC1 and EC1
                                                                                                  EC2
                                                                                                  EC3
                                                                                                  EC4
                                                                                                  WC1
                                                                                                  WC2
                                                                                                  W1
and then the same for  EC2 and                                                EC1
                                                                                                  EC2
                                                                                                  EC3
                                                                                                  EC4
                                                                                                  WC1
                                                                                                  WC2
                                                                                                  W1
 
A value is expected for each postcode pair but my problem is that all postcodes are stored in one postcode table and 0 or denotes if it is a collection or a delivery.
 
I dont think i need  OR here as i need all four criteria  :
a postcode (ec1) collection (1) a postcode (ec2)  delivery (0)
 
Thanks
IP IP Logged
Senthil Raj
Newbie
Newbie
Avatar

Joined: 02 Aug 2010
Location: India
Online Status: Offline
Posts: 27
Quote Senthil Raj Replybullet Posted: 24 Aug 2010 at 1:14am
the or condition should be used as
 
Global NumberVar EC1EC1 := EC1EC1+
(If ((Left({TableA.adad_postalcode},3) ="EC1") and {TableA.adad_addressnumber} = 0 )
or
    ((Left({TableA.adad_postalcode},3) ="EC2") and {TableA.adad_addressnumber} =1)

      then 1
             else 0);
 
try this
IP IP Logged
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Posted: 24 Aug 2010 at 7:01am
Hi Senthil
 
This does not work as i need a pickup postcode and a drop postcode. The OR allows me to have either but  not both.
 
My problem that the postcodes is stored in one table  and the switch which specifies if it is a pick or delivery in another.
 
any other ideas ?
IP IP Logged
Senthil Raj
Newbie
Newbie
Avatar

Joined: 02 Aug 2010
Location: India
Online Status: Offline
Posts: 27
Quote Senthil Raj Replybullet Posted: 24 Aug 2010 at 8:43pm
 TableA.adad_postalcode is from one table and the condition is checked as record by record since u cant not have 2 values (EC1 and EC2) in one record your and condition will always return false only
IP IP Logged
eTest
Newbie
Newbie


Joined: 17 Aug 2010
Online Status: Offline
Posts: 8
Quote eTest Replybullet Posted: 24 Aug 2010 at 11:57pm
Would there be a way around this issue?
 
Sorry for being a pain but i am still pretty new at this.
IP IP Logged
Senthil Raj
Newbie
Newbie
Avatar

Joined: 02 Aug 2010
Location: India
Online Status: Offline
Posts: 27
Quote Senthil Raj Replybullet Posted: 25 Aug 2010 at 1:08am

Thats Fine

if you give the sample record as in the database and your required output we can solvethis issue
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