Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with Conditional statment Post Reply Post New Topic
Author Message
Capson
Newbie
Newbie
Avatar

Joined: 23 Jan 2013
Location: United States
Online Status: Offline
Posts: 20
Quote Capson Replybullet Topic: Help with Conditional statment
     Posted: 07 Feb 2013 at 4:42pm
Hello, I have

Table name is 360

Conditional_Client
If {'360_'.Relationsnhip}="Client" then {'360_'.Relationsnhip}

Then make Summery:

Field to Summarize: Conditional_Client
Calculate this Summary: Count

CntClient
If {'360_'.Relationsnhip}="Client" then Count ({@Conditional_Client}, {'360_'.Relationsnhip})

(The Bold is the Summary field)

Finally

Conditional_Score
If {@CntClient}<=2 and {'360_'.Relationship}="Client" then 0
else
{'360_'.Score}

And this works, but.

I have one last problem I REALLY need to change the... then 0 ​to a hyphen "-" or Null but when I do this I get a error when trying to save the formula

Conditional_Score
If {@CntClient}<=2 and {'360_'.Relationsnhip}="Client" then "-"
else
{'360_'.Score}

I get "A string is required here" and the {'360_'.Score} is hi-lighted but I need the {'360_'.Score} to be there.

So close!!!

Thanks

Edited by Capson - 07 Feb 2013 at 4:43pm
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 08 Feb 2013 at 1:04am
Hi

Instead of giving "-" give 0 some thing like :

Conditional_Score
If {@CntClient}<=2 and {'360_'.Relationsnhip}="Client" then 0
else
{'360_'.Score}

Now right click on the field and go in Format Field--Number Tab--Customize-select again Number tab.  You will find one drop down with name "Show Zero Values as :"

Select drop down and choose '-' .  It will display '-' when the value is zero 0
Thanks,
Sastry
IP IP Logged
Capson
Newbie
Newbie
Avatar

Joined: 23 Jan 2013
Location: United States
Online Status: Offline
Posts: 20
Quote Capson Replybullet Posted: 08 Feb 2013 at 2:39am
Hello Sastry,
Thank you.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 08 Feb 2013 at 3:38am
Another way to do this would be to change the formula:
 
If not ({@CntClient}<=2 and {'360_'.Relationsnhip}="Client") then {'360_'.Score}
 
This will return a null value when the condition is met.
 
-Dell
IP IP Logged
Capson
Newbie
Newbie
Avatar

Joined: 23 Jan 2013
Location: United States
Online Status: Offline
Posts: 20
Quote Capson Replybullet Posted: 08 Feb 2013 at 6:07am
Hello Dell, thanks for your responce.
I tried your formula but dose work, in that the condition is never being met.
I would like to use it if I can be get it to work.

Edited by Capson - 08 Feb 2013 at 6:09am
IP IP Logged
Capson
Newbie
Newbie
Avatar

Joined: 23 Jan 2013
Location: United States
Online Status: Offline
Posts: 20
Quote Capson Replybullet Posted: 08 Feb 2013 at 6:16am
Sorry, I refreshed now it is working.
But I do not get a null I still get 0.00
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 08 Feb 2013 at 6:48am
Did you include the parentheses after the not?
 
Another way to write it would be something like this:
 
If {@CntClient}>2 and {'360_'.Relationsnhip}<>"Client") then {'360_'.Score}
 
-Dell
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 08 Feb 2013 at 6:52am
Ok, in the formula you should have an option to set how the formula handles nulls - there are two options:  "Exceptions For Nulls" and "Default Values For Nulls".  Set it to "Exceptions For Nulls".
 
-Dell
IP IP Logged
Capson
Newbie
Newbie
Avatar

Joined: 23 Jan 2013
Location: United States
Online Status: Offline
Posts: 20
Quote Capson Replybullet Posted: 08 Feb 2013 at 8:53am
Dell, I tried both choices, neither had an effect.

All the brackets are present and accounted for.

I have not tryed the second version of the formula yet I will give it a try as well

Edited by Capson - 08 Feb 2013 at 8:54am
IP IP Logged
Capson
Newbie
Newbie
Avatar

Joined: 23 Jan 2013
Location: United States
Online Status: Offline
Posts: 20
Quote Capson Replybullet Posted: 09 Feb 2013 at 10:04am
Here is a solution that uses my original conditional_Score formula.

Create a formula "Null" when the editor opens click close and save with out doing anything
then

Conditional_Score
    If {@CntClient}<=2 and {'360_'.Relationship}="Client" then 0
      else
        {'360_'.Score}

Becomes
Conditional_Score
    If {@CntClient}<=2 and {'360_'.Relationship}="Client" then ToNumber{@Null}
      else
       {'360_'.Score}

This shows null when the condition is met
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