Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: how do i include nulls in my formula Post Reply Post New Topic
Author Message
sanchezgmc06
Senior Member
Senior Member
Avatar

Joined: 21 Jan 2011
Online Status: Offline
Posts: 107
Quote sanchezgmc06 Replybullet Topic: how do i include nulls in my formula
     Posted: 04 Feb 2014 at 9:35am
Basically i want to say if the field is null then use chr(111) and i would like to add this to the following formula:
 
if {cans_ansa_assessment.cans_05_responsive_dsr_Value}= "0" then
chr(120) else
chr(111)
 
What is happening is that if the question is not answered or null then crystal reports doesnt return anything and the goal is to retrun chr(111) because then i would have a box with no x in it displayed. 
 
Help
 
thank you
IP IP Logged
praveeng
Senior Member
Senior Member
Avatar

Joined: 11 Jul 2011
Online Status: Offline
Posts: 165
Quote praveeng Replybullet Posted: 04 Feb 2014 at 9:46am
Hi,

Change your formula as below,

If {cans_ansa_assessment.cans_05_responsive_dsr_Value}= "0" Then
Chr(120)
Else If IsNull({cans_ansa_assessment.cans_05_responsive_dsr_Value}) Then
Chr(111)

HTH.

--Praveen G
Praveen Guntuka,
praveen_guntuka@yahoo.com
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Feb 2014 at 11:07am
IMO
You can either make the formula use 'default values for nulls' or you have to address teh NULL As the first criteria other wise it stops evaluating on a NULL
 
 
if isnull({cans_ansa_assessment.cans_05_responsive_dsr_Value}) then chr(111) else 
chr(120)
 
IP IP Logged
sanchezgmc06
Senior Member
Senior Member
Avatar

Joined: 21 Jan 2011
Online Status: Offline
Posts: 107
Quote sanchezgmc06 Replybullet Posted: 04 Feb 2014 at 12:50pm
Worked!
 
Thank you
IP IP Logged
sanchezgmc06
Senior Member
Senior Member
Avatar

Joined: 21 Jan 2011
Online Status: Offline
Posts: 107
Quote sanchezgmc06 Replybullet Posted: 04 Feb 2014 at 1:26pm
Actually it did not work
 
I need it to show chr(111) if the field is null and if its anything other than the value i am defining
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Feb 2014 at 2:49pm
sorry, not following
you need it to be chr(111) if it is null and if it is not null what do you want it to be?
IP IP Logged
lolly54
Groupie
Groupie
Avatar

Joined: 25 Sep 2011
Online Status: Offline
Posts: 58
Quote lolly54 Replybullet Posted: 04 Feb 2014 at 10:12pm
Try also...

If (IsNull({cans_ansa_assessment.cans_05_responsive_dsr_Value}) or If ({cans_ansa_assessment.cans_05_responsive_dsr_Value} = "") Then
Chr(111)
else (you can define the rest)

I found that in some cases, the = "" or = " " help to capture the supposed to be null field.
IP IP Logged
sanchezgmc06
Senior Member
Senior Member
Avatar

Joined: 21 Jan 2011
Online Status: Offline
Posts: 107
Quote sanchezgmc06 Replybullet Posted: 05 Feb 2014 at 3:37am
Dblank
Yes, my initial formula says if the value is 0 then chr(120) but if its anything else then chr(111) however when there is nothing selected at the user end then there is just a blank space. Instead of the blank space I would like for it to return a chr(111)

The reason behind this is I am displaying an empty box with chr(111) however when the value "0" is selected I need to display a box with an x inside of it.

hope that helps, sorry for the confusion

@Lolly54 as soon as I get into the office I will give it a try
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Feb 2014 at 6:44am
So the basic rule still applies that unless you have the system or formula set to use defualt values for nulls the formula will stop evaluating when it hits the NULL unless you state what to do with the NULL as the first part of the formula. In your case I think what you are asking is for any record where the result is "0" then the chr(120) otherwise you want the chr(111) but your reults are coming back blank when the value is NULL.
Since this appears to be a string data type you can use your original formula of
 
if {cans_ansa_assessment.cans_05_responsive_dsr_Value}= "0" then
chr(120) else
chr(111)
 
but just make sure to flip the formual option inside the formula editor to 'Use default values for nulls'
 
If you can't do that then you have to use something like
 
if isnull({cans_ansa_assessment.cans_05_responsive_dsr_Value}) or {cans_ansa_assessment.cans_05_responsive_dsr_Value}<> "0" then chr(111) else chr(120)
IP IP Logged
sanchezgmc06
Senior Member
Senior Member
Avatar

Joined: 21 Jan 2011
Online Status: Offline
Posts: 107
Quote sanchezgmc06 Replybullet Posted: 05 Feb 2014 at 8:03am
Thank you!
 
I ended up using the followin formula with a string
 
x= filled in box
o=empty box
 
IF ISNULL ({cans_ansa_assessment.cans_med_comp_dsr_Value})
THEN
'o o o o '
ELSE
IF {cans_ansa_assessment.cans_med_comp_dsr_Value}= "0" THEN
'x o o o'
ELSE
IF{cans_ansa_assessment.cans_med_comp_dsr_Value}= "1" THEN
'o x o o'
ELSE
IF {cans_ansa_assessment.cans_med_comp_dsr_Value}= "2" THEN
'o o x o'
ELSE
IF {cans_ansa_assessment.cans_med_comp_dsr_Value}= "3" THEN
'o o o x'
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