COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: kgl_m on 05 Jun 2009 02:37:05 PM

Title: Display set text when string is null?
Post by: kgl_m on 05 Jun 2009 02:37:05 PM
Hi, I thought this was fairly simple but apparently I'm missing something...

We have a field that can contain text or null. This field is in a List Group Header, so I would like it to display the text "Others" when there are null values that don't fit anywhere else. Right now it just gives us a header with no text for all values that lack a name.

I tried various variations of this text, but it didn't work. Could anyone help?

case when cast([Presentation Layer].[Organizations].[Lead Department],varchar(20)) =  '' then 'Others'
else [Presentation Layer].[Organizations].[Lead Department]
end
Title: Re: Display set text when string is null?
Post by: jayani on 05 Jun 2009 02:52:32 PM
Hi,

There is a solution.
Go to the column for which you want to display 'Others' for null values.
In Properties pane-> Data Format -> e.g. Text (Select the type which suits the column's datatype)
-> In 'Missing value characters' type 'Others'.
Now, whereever null values are there for that particular column, 'Others' will be displayed.... :)

~Jayani
Title: Re: Display set text when string is null?
Post by: blom0344 on 06 Jun 2009 04:12:31 PM
null <> empty string !!

Other than by using formatting, the best option is the coalesce function:

coalesce([somedataitem],'Other')

You should interpret a null as a missing or 'unknown' value, rather than an empty string.
(which is why your expression fails)