COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: subhash on 17 Jan 2008 03:40:13 AM

Title: regarding dynamically adding columns
Post by: subhash on 17 Jan 2008 03:40:13 AM
hi,
  i have 2 prompts: From date and To date.

i will select from date as 01/01/2007 and To date as 01/01/2008. Now the difference between them is 12 months. so i have to get the 12 columns to be added to the report. if the difference is 15 then 15 cols are to be added to the report.

the sample is given below.

i have selected 01/01/2007(From date) and 01/04/2007 so the diff in months is 4. so my report should look like this

Sno  From Date  ToDate  Jan-07  Feb-07  March-07  April-07.
--------------------------------------------------------------
1  01/01/07  01/04/07    40         50         60          60


like this. this is my urgent requirement.
Title: Re: regarding dynamically adding columns
Post by: almeids on 17 Jan 2008 09:46:49 AM
You have 2 choices I can think of:

(1) Use a crosstab
(2) If there's a maximum number of periods, you could create a list report with that many columns and conditionally suppress the ones you don't need.

Unless there are unusual/advanced formatting requirements you can't do with a crosstab, (1)would be the much simpler solution.
Title: Re: regarding dynamically adding columns
Post by: Suraj on 18 Jan 2008 04:57:12 PM
I second using crosstab for this purpose.
The only thing you have to be aware is that if your months are just Jan, Feb etc...
then you may have Jan of 2006 overlapped with Jan of 2007. Therefore, your months need to be unique regardless of years.