COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: abcuser on 25 May 2015 04:21:57 AM

Title: 'data type error' in conditional style trying to set null to behave like zero
Post by: abcuser on 25 May 2015 04:21:57 AM
Hi,
I have Cognos 10.2.1 fixpack 6 Report Studio using DQM package accessing Cognos TM1 10.1.1 fixpack 2 cube.

I would like to colour the background of cell with red if Quantity_A is higher then Quantity_B.
I created Conditional Style with expression:
[Query1].[Quantity_A]>[Query1].[Quantity_B]
and set this expression to red color.
Note: This is simple sample. My sample has several conditions separated with AND statement.

Above expression is working fine if Quantity_B is not null. But in my case Quantity_B can also be null. But in this case I need to set null to behave like 0.
I tried this:
[Query1].[Quantity_A]>if([Query1].[Quantity_B] is null) then (0) else ([Query1].[Quantity_B])
but I am getting error:

RSV-VAL-0002 Invalid expression [Query1].[Quantity_A]>if([Query1].[Quantity_B] is null) then (0) else ([Query1].[Quantity_B])
CRX-API-0003 A data type error occurred at or near ...
The operand types ('integer,integer,double') for operator 'Conditional Expression' are not compatible

Just for test I replaced column name with "1":
[Query1].[Quantity_A]>if([Query1].[Quantity_B] is null) then (0) else (1)
and command runs without an error. So "if" statement is correct, just data types are incorrect.

Any idea how to fix this?
Thanks.
Title: Re: 'data type error' in conditional style trying to set null to behave like zero
Post by: bdbits on 26 May 2015 10:46:19 AM
The expression is not quite right. I think you need something like this:

if ([Query1].[Quantity_B] is null) then ([Query1].[Quantity_A]>0) else ([Query1].[Quantity_A]>[Query1].[Quantity_B])
Title: Re: 'data type error' in conditional style trying to set null to behave like zero
Post by: Lynn on 26 May 2015 11:01:53 AM
I think the conditional style expression wants a Boolean true or false result. You might try something like this:


(
  [Query1].[Quantity_B] is null
  and
  [Query1].[Quantity_A] > 0
)
or

  [Query1].[Quantity_B] is not null
  and
  [Query1].[Quantity_A] > [Query1].[Quantity_B]
)