Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: remove null & empty values Post Reply Post New Topic
Author Message
pedraza4
Newbie
Newbie


Joined: 05 Apr 2010
Online Status: Offline
Posts: 4
Quote pedraza4 Replybullet Topic: remove null & empty values
    Posted: 05 Apr 2010 at 6:42pm
I created a report with multiple fields. I would like to create a generic formula in which it evaluates all the values and if it found a null or empty value it will be replaced by a 'N/A'. I was trying to use the following formula for one of the database value:

if isnull({PID_.CND7/T_EXPRESSION#EXPRESSION}) then "N/A" else {PID_.CND7/T_EXPRESSION#EXPRESSION} = {PID_.CND7/T_EXPRESSION#EXPRESSION}

but I had the error a string is required here.

thanks
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 Apr 2010 at 3:31am
in your if statement, both parts need to return the same type of data.  In your example, the if is returning a string, but the else is returning...something else.  They need to match.
 
HTH
IP IP Logged
pedraza4
Newbie
Newbie


Joined: 05 Apr 2010
Online Status: Offline
Posts: 4
Quote pedraza4 Replybullet Posted: 06 Apr 2010 at 5:14am
for the formula posted I change the data to the same type and it works.

My concern is that I have approx. 140 fields which I would like to evaluate if there is a blank or Null value in order to replace it with a N/A.

If is possible to change all the variable to string an have a generic formula to evaluate all the fields?? I would like the following:

if {mydata}='NULL' then 'N/A'

else if {mydata} = "" then 'N/A'

else {mydata}

when I refer to mydata is approx 140 fields in the report.

thanks
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 06 Apr 2010 at 6:58am
The bad part is that you would have to create 140 seperate formulas to replace the fields.  They could all call the same formula, just passing the field value to it and returning the result.
 
I hope this helps.
IP IP Logged
pedraza4
Newbie
Newbie


Joined: 05 Apr 2010
Online Status: Offline
Posts: 4
Quote pedraza4 Replybullet Posted: 06 Apr 2010 at 7:27am
I will create the general function, my only question is how I can change all the fields as string??

or

how can I assign a "N/A"to a boolean field??
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 06 Apr 2010 at 9:20am

I was assuming that all the data types would be the same.  But if they are not, then you probably would need to customize the function(s) for each data type.  As far as boolean goes, is it ever 'NULL'? I have seen different data sources handle boolean differently.  Other than doing some testing to see what the ISNULL function returns for each type of data value.  Also with boolean values, do you want to return "N/A" if is false?

 
Lots of luck.
IP IP Logged
pedraza4
Newbie
Newbie


Joined: 05 Apr 2010
Online Status: Offline
Posts: 4
Quote pedraza4 Replybullet Posted: 06 Apr 2010 at 10:25am
Is there is a way to change the data type of the field.

ex change all booleans fields to string

??
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 06 Apr 2010 at 10:53am
Not without using a formula or using a stored procedure to pre-process the data.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.