COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cbyrne on 14 Jul 2011 07:38:43 AM

Title: Colour Conditions/Variables for NULL Empty Fields in list report
Post by: cbyrne on 14 Jul 2011 07:38:43 AM
Hello, i have created a list report but need to create a colour condition on a null field, does anyone know how to do this.  Below is my current variable which doesn't do anything.  I need it to show red when the part number row is empty.



String Variable
CASE [Query1].[Part Number] WHEN ' ' THEN 'RED' ELSE ' ' END


Many Thanks

Chris
Title: Re: Colour Conditions/Variables for NULL Empty Fields in list report
Post by: CognosPaul on 14 Jul 2011 07:54:31 AM
Boolean variable
[Query1].[Part Number] is null

String variable
CASE WHEN [Query1].[Part Number] is null THEN 'RED' END
Title: Re: Colour Conditions/Variables for NULL Empty Fields in list report
Post by: cbyrne on 14 Jul 2011 08:20:07 AM
Thanks PaulM, i have just done something similar and i think it works but i will try your way. Is the below similar to yours?



Data Item = Part Number NULL
coalesce([Query1].[Part Number],' ')


String Variable
CASE [Query1].[Part Number NULL] WHEN ' '  THEN 'RED' ELSE '' END


Thanks


Chris
Title: Re: Colour Conditions/Variables for NULL Empty Fields in list report
Post by: Lynn on 14 Jul 2011 12:39:50 PM
Looks to me like you are using a blank space surrounded by quotes in your original post. This is not the same as null so your string variable would always hit the "else" portion of the clause.

Your last post looks like it would work, but seems to introduce a wee tiny bit of overhead and complexity that you don't really need. Your coalesce transforms null to blank and then allows your string variable expression to work properly.

I think both of Paul's suggestions are a little more straightforward. Since I am somewhat boolean in many aspects of my life I'd opt for a boolean variable instead of string when there are really only two possible outcomes.
Title: Re: Colour Conditions/Variables for NULL Empty Fields in list report
Post by: cbyrne on 15 Jul 2011 08:51:24 AM
Yes thanks Lynn and PaulM, I did seem to complicate it and decided to go with Paul's method.


Many Thanks

Chris