COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: div_1234 on 01 Sep 2011 12:05:46 PM

Title: error
Post by: div_1234 on 01 Sep 2011 12:05:46 PM

hi
I am creating new data item and i am putting expression like this ,i m getting error
what is wrong with this code?


if ([M].[v].[Col] = 'Pass / Fail') then
if ([M].[v].[W] = 1 ) then  replace([M].[v].[W],'1','P')
else (' F')



error : Parsing error near the position 73

Title: Re: error
Post by: Lynn on 01 Sep 2011 03:10:17 PM
You need parentheses around each portion of the "if", the "then" and the "else". You also might need an "else" to go with the outer if statement.

It looks to me like the replace function in this case isn't necessary. You also need to pay attention to data types....is [M].[v].[W] a number or a string? If it is a number you'd use the = 1 condition. If it is a string you might want to enclose the 1 in single quotes.

  if ( [M].[v].[Col] = 'Pass / Fail' )
then (   if ( [M].[v].[W] = 1 )
       then ( 'P' )
       else ( 'F' )
else ( '' )