COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: jd on 23 May 2011 10:28:25 AM

Title: How to use function "Left" in report studio..
Post by: jd on 23 May 2011 10:28:25 AM
Hi I have question with function "left"..
here is my function "left" using with series7 Cognos Query, how should I write this one in report studio.

Left function is not working in Report studio. please anyone have any idea??

if ( left([Available Tables].[Product Codes].[product], 1  ) =  '9'  ) then (decode( [Available Tables].[Product Codes].[AAA] , '9505' , 'Y','9519','Y', 'N'  )) else (  'N'  )
Title: Re: How to use function "Left" in report studio..
Post by: kattaviz on 23 May 2011 01:42:30 PM
Hi,

Try using substring.
Title: Re: How to use function "Left" in report studio..
Post by: jd on 23 May 2011 01:58:57 PM
I did try with substring but "N' value did not change to 'Y'
Title: Re: How to use function "Left" in report studio..
Post by: tosravan on 23 May 2011 02:00:20 PM
Your left function is correct. Check your condition - decode function (Oracle?)


Quote from: d.laxmi on 23 May 2011 10:28:25 AM
Hi I have question with function "left"..
here is my function "left" using with series7 Cognos Query, how should I write this one in report studio.

Left function is not working in Report studio. please anyone have any idea??

if ( left([Available Tables].[Product Codes].[product], 1  ) =  '9'  ) then (decode( [Available Tables].[Product Codes].[AAA] , '9505' , 'Y','9519','Y', 'N'  )) else (  'N'  )
Title: Re: How to use function "Left" in report studio..
Post by: blom0344 on 23 May 2011 02:42:40 PM
Cognos has perfectly good alternatives for RDBMS functions: use substring combined with a CASE construction:

CASE
WHEN
sustring([Available Tables].[Product Codes].[product], 1,1) = '9'
THEN
(CASE
WHEN
[Available Tables].[Product Codes].[AAA]  = '9505' THEN 'Y'
WHEN
[Available Tables].[Product Codes].[AAA]  = '9519' THEN 'Y'
ELSE 'N'
END)
ELSE 'N'
END