COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: sspk on 07 Feb 2008 09:10:21 AM

Title: change column names dynamically
Post by: sspk on 07 Feb 2008 09:10:21 AM
  HI All,
Sorry for asking the question again (it's urgent)
i have to generate a report which will have data-items like data_year,data_month,trx_1,trx_2,....
i have the trx_data_buckets in the table itself
when data_month =NOV 2007 then trx_1=nov-07,trx_2=oct-07,trx_3=sep-07....
when data_month=OCT 2007 then trx_1=oct-07,trx_2=sep-07,trx_3=aug-07....
when data_month=SEP 2007 then trx_1=sep-07,trx_2=aug-07,trx_3=jul-07....
I have a prompt on data_month so when i select a month it should display as above.
Title: Re: change column names dynamically
Post by: Suraj on 07 Feb 2008 09:22:36 AM
create a data item with a case statement and put in the column or column header depending upon what you want (labels or values).
case
when data_month =NOV 2007 then 'November 07'
when data_month=OCT 2007 then 'October 07'
when data_month=SEP 2007 then 'September 07'
...
else
end
Title: Re: change column names dynamically
Post by: sspk on 08 Feb 2008 09:48:27 AM
Please can you explain it with steps,because i am not getting it
Title: Re: change column names dynamically
Post by: Suraj on 08 Feb 2008 10:29:24 AM
Quote from: Suraj Neupane on 07 Feb 2008 09:22:36 AM
create a data item with a case statement and put in the column or column header depending upon what you want (labels or values).
case
when data_month =NOV 2007 then 'November 07'
when data_month=OCT 2007 then 'October 07'
when data_month=SEP 2007 then 'September 07'
...
else
end
After you create the data item,
1. if you want to add columns with that value, just drag and drop.
2. if you are just wanting to change the label of column header, click on the header, under properties-->text source-->Source type; change that to Data item value and below 'Data item value', select the new data item created above.
This will change the header.
Title: Re: change column names dynamically
Post by: sspk on 11 Feb 2008 09:00:55 AM
Quote from: Suraj Neupane on 08 Feb 2008 10:29:24 AM
After you create the data item,
1. if you want to add columns with that value, just drag and drop.
2. if you are just wanting to change the label of column header, click on the header, under properties-->text source-->Source type; change that to Data item value and below 'Data item value', select the new data item created above.
This will change the header.

Thank you , very much,there is a problem whenever i am changing the colmn header name it is also changing the values in the column .I am doing like this
under properties--->aggregate function(none for column header)
        properties--->aggregate function(total for column body) and even in the case statement i had a problem
because data _month =11 it's not NOV 2007
can u help me out
Title: Re: change column names dynamically
Post by: Suraj on 11 Feb 2008 12:59:34 PM
You need to change the column headers' display text only, not the data item.
select column header, properties, text source and specify what value you want to display in the header.