COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: hommer on 10 Sep 2010 01:29:53 PM

Title: How to feed variable data to column?
Post by: hommer on 10 Sep 2010 01:29:53 PM
Hi, all,

In the report studio, how do I make a column's data fed from a variable?

I have created myVar = ltrim([rpt].[view].[field1], '0').

The reason I cannot directly use ltrim on the column is that I have to feed field1 as input parameter to a custom function, which is expecting native data (with all the leading zeros).

Thanks!
Title: Re: How to feed variable data to column?
Post by: ksvchowdary on 10 Sep 2010 02:28:46 PM
I am not sure what you are trying to get.Here is the exact syntax of Ltrim.

ltrim
Returns string_exp with leading spaces removed.
Syntax
ltrim ( string_exp )

Ex: ltrim(field1)
it returns only leading leading spaces removed.If you dont need zeros ( 0 's ) use left or right function.

ex: you have a number like  00012345 , you need only 12345.you can use right(00012345,5).but make sure leading zeros have same fixed width in all values.
Title: Re: How to feed variable data to column?
Post by: hommer on 10 Sep 2010 03:37:33 PM
Thank you for your reply.

My trim part is working. That serves my column one need.

However I have another column two on the report and its data will come from a function on the database. That function needs an input parameter, which is the same field as column one but without the trimming part.

What is why I tried to asign the trimmed data to a local variable then feed to col one, and feed the untrimmed same field to my function to get the data for col two.

On the expression for col one, it wouldn't take myVar or =myVar as valid entry.

Maybe using a variable is not the right solution.

Then, again, when I tried to bring in the same field 2nd time, one with trim and one without. It didn't like that either. Cognos will make them same. ???
Title: Re: How to feed variable data to column?
Post by: hommer on 10 Sep 2010 04:27:41 PM
Ok, case closed.

Query calculation did it.