COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Nithesh UC on 26 Feb 2013 03:54:53 AM

Title: Conditional Formatting based on user's selection
Post by: Nithesh UC on 26 Feb 2013 03:54:53 AM
Hi Guys,

I am trying to format a column based on User's input value
There is a requirement where i need to format the column(Speed) based on User's input.
If user is giving <40 then RED and >40 and <80 is Blue and >80 is Green.
So In Advanced conditional style I'm writing a condition like "if (ParamDisplayValue('SpdLimit') < 40)
then ParamDisplayValue('SpdLimit')"
But I'm getting an error saying
"RSV-VAL-0002 Invalid expression if (ParamDisplayValue('SpdLimit') < 40)
then ParamDisplayValue('SpdLimit'). CRX-API-0003 A data type error ocurred at or near the position '32' in expression: 'if (ParamDisplayValue('SpdLimit') < 40)
then ParamDisplayValue('SpdLimit') '. The operand types ('string (varchar),integer') for operator '<' are not compatible."

FYI:I'm using Textbox Prompt for the Speed.
Title: Re: Conditional Formatting based on user's selection
Post by: blom0344 on 26 Feb 2013 06:33:37 AM
Why not ParamValue when comparing with a numerical value?
Title: Re: Conditional Formatting based on user's selection
Post by: dawells on 01 Mar 2013 12:31:14 PM
I have used Advanced Conditional Styles and found that they don't like conditional statements like if/then/else and case imbedded in them. Is it possible to pass the user's input to a query data item, then drive your conditional style of that query? Let me know if you this helps. Thanks.
Title: Re: Conditional Formatting based on user's selection
Post by: Lynn on 01 Mar 2013 02:09:32 PM
Your expression for the advanced style should be boolean so it evaluates to true or false. Also, your expression should refer to a data item in your query. You can use the report casting function to convert the text input from the user to the desired datatype for comparison to your query item.

For example, you could define this expression and then click the pencil icon next to style and set the background color to red.
[Query1].[YourItem] < string2int64 ( ParamDisplayValue('SpdLimit') )

You can add more conditions to the style to deal with blue and green, but presumably you have another parameter where you'd get the other number from the user (unless 80 is a hard-coded set figure).

Hope this helps.
Title: Re: Conditional Formatting based on user's selection
Post by: Nithesh UC on 10 Mar 2013 07:40:15 AM
First of all Thank u guys for all your suggestions..

I have achieved it like by taking user's selection to a query item and defining some identity in the query for the particular speed limit.
Like If(Spd < 'p_LowSpd') then ('Red') else if(Spd between 'p_LowSpd' and 'p_HSpd' ) then ('Green') else ('Blue') name this query as 'Spd'
Then for that query based on the identity i did advanced conditional style.
if 'Spd' = 'Green' edit the background color as Green and repeat this for the remaining.


Thanks
uC