COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: kumar_s on 16 Jul 2009 01:51:31 PM

Title: Need to capture value in a variable
Post by: kumar_s on 16 Jul 2009 01:51:31 PM
I have a variable ‘emp_name’, dynamic in length, which has the the employee’s name in the last, first format separated by a comma.  What I want to do is to get the last name into a variable. 

In SAS, I would have done

Lname=substr(emp_name,1,’,’) ;

I am not really sure how I’d do this using COGNOS BI and would appreciate any help I can get.
Title: Re: Need to capture value in a variable
Post by: Sridevi on 17 Jul 2009 12:31:24 AM
Try this....

substring(emp_name,1,position(',',emp_name))

Thanks,
Sridevi
Title: Re: Need to capture value in a variable
Post by: Gopinath on 17 Jul 2009 03:46:07 AM
Create a dataitem with the expression that Sridevi posted but add -1 to get rid of the comma (,) at the end

substring(emp_name,1,position(',',emp_name) -1)
Title: Re: Need to capture value in a variable
Post by: kumar_s on 21 Jul 2009 07:30:47 AM
Sridevi/Gopinath/et al:

Thank you.  You people are great!!! That worked..


Regards

Kumar