COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Kevvukeka on 25 Jan 2013 06:19:51 AM

Title: Using a String in Style variable..
Post by: Kevvukeka on 25 Jan 2013 06:19:51 AM
Hi Everyone,

I have few values in a column. few are equal to 0 and few are greater than 1 and few are negative numbers. I need to color the cells based on the values. for e.g red for -1, blue for 0 and green for greater than 1.
I used the following method
case [variance]
when('<0') then ('Red')
when ('0') then ('Blue')
when('>1') then ('Green')
end.

i selected the string1 in style variable and checked the 'RED' option in conditional explorer tab, selected the Background color as "RED" and run the report. But it shows me "Internal Error". Did I missed anything.

Please help..

Thanks & Regards,
Title: Re: Using a String in Style variable..
Post by: MFGF on 28 Jan 2013 08:38:17 AM
What data type is your column? Testing when('<0') will not return a true result unless your item is a character or char and actually contains the value '<0'

Is your item a numeric or a string?

MF.
Title: Re: Using a String in Style variable..
Post by: Kevvukeka on 29 Jan 2013 01:24:42 AM
Hi MF,

My Data item is numeric
Title: Re: Using a String in Style variable..
Post by: MFGF on 29 Jan 2013 04:14:14 AM
How about:

CASE  WHEN [variance] < 0 THEN 'Red'
WHEN [variance] = 0 THEN 'Blue'
WHEN [variance] > 1 THEN 'Green'
ELSE 'Other' END
Title: Re: Using a String in Style variable..
Post by: Kevvukeka on 29 Jan 2013 01:00:57 PM
Hi MF,

I used the expression as below:

case
when ([Query1].[variance])<0 then 'RED'
when([Query1].[variance])>0 then 'BLUE'
when([Query1].[variance])>10 then 'GREEN'
else 'OTHER'
end

selected the variance column.selected the style variable->string1->conditional explorer->selected "Red", gave the background color as "Red". repeated for all 3 colors. every time double clicked the green bar and selected the options but still enitre column takes only one color.

My variance data is as follows:
11.41
6.38
2.09
0.40
2.97.

Thanks
Title: Re: Using a String in Style variable..
Post by: MFGF on 30 Jan 2013 07:07:31 AM
Hi,

Your expression will always evaluate to the BLUE condition for the data values you supplied. In my expression I had =0 but in yours you have >0 and all your values are >0. Once a condition evaluates to TRUE no further processing of the expression is done.

You would need to modify your expression as follows:

case
when ([Query1].[variance]<0) then 'RED'
when([Query1].[variance]>=0 and [Query1].[variance] <=10) then 'BLUE'
when([Query1].[variance]>10) then 'GREEN'
else 'OTHER'
end

Title: Re: Using a String in Style variable..
Post by: Kevvukeka on 31 Jan 2013 02:52:17 AM
Thanks a Lot MF. Thanks for your patience. I got it now..

Regards,
PS
Title: Re: Using a String in Style variable..
Post by: MFGF on 31 Jan 2013 11:04:21 AM
Great! Thanks for the update, and you're welcome! :)

MF.