COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: katdbc on 23 Sep 2010 09:51:09 AM

Title: writing an expression
Post by: katdbc on 23 Sep 2010 09:51:09 AM
i am getting an error when i write a calculation like thi

IF (([Units].[Contract Code Dim].[Physical Damage Insurance] >0 )  or ([Units].[Contract Fact (Units)].[Non-DTF Physycial Damage Insurance] >0)) THEN ('Y') else NULL

what is wrong or is there better way to do it!!!!!
Title: Re: writing an expression
Post by: technomorph on 23 Sep 2010 10:16:17 AM
Try:

IF ([Units].[Contract Code Dim].[Physical Damage Insurance] > 0 Or [Units].[Contract Fact (Units)].[Non-DTF Physycial Damage Insurance] > 0) THEN ('Y')
ELSE
( NULL )
Title: Re: writing an expression
Post by: katdbc on 23 Sep 2010 10:44:45 AM
I tried that and it is throwing me an error!!!!!
I donno y !!!!!

error is
a genral exception has occured during the operation"prepare",
the data types of the operands ">" are not compatible

and many more errors!!!!
Title: Re: writing an expression
Post by: Lynn on 23 Sep 2010 10:55:58 AM
Are those columns numbers? It seems you could get that error if you are doing > operation with a non-numeric value.
Title: Re: writing an expression
Post by: technomorph on 23 Sep 2010 10:59:56 AM
First try the following. I'm not entirely sure it will work with string data-types, but worth a go:

IF ([Units].[Contract Code Dim].[Physical Damage Insurance] > '0' Or [Units].[Contract Fact (Units)].[Non-DTF Physycial Damage Insurance] > '0') THEN ('Y')
ELSE
( NULL )

Otherwise, check the data-types of the data items:

Right mouse click the data item in the Insertable Objects pane > select Properties > Data Type

Then make sure you're comparing like data-types in the If Statement. You may need to use a Cast function:

cast ( exp, datatype_specification )
Title: Re: writing an expression
Post by: katdbc on 23 Sep 2010 03:13:09 PM
awesum pppl!!!!!!

i reali had the datatype problem,i took the wrong column which was char!!!!!!!

thank you so much!!!!!!!

btw im a noob in cognos  and i have just started!
plz bare me