COGNOiSe.com - The IBM Cognos Community

Legacy Business Intelligence => COGNOS ReportNet => Report Studio => Topic started by: Taboka on 25 Jan 2008 05:39:25 AM

Title: 2 Months ago date filter
Post by: Taboka on 25 Jan 2008 05:39:25 AM
Hi all,
I am using the filter below to get values for 2 months ago:
[Recharge Monthly].[Time Month].[Time Month Key]=(if( substring(to_char(?FromDate?),5,2) = 01)
then ((?FromDate? - 89)-1)
else if( substring(to_char(?FromDate?),5,2) = 02)
then (?FromDate? - 89)
else (?FromDate? - 2))

It works for the instance where the month selected is January,i.e I get results for the previous Dec.However when I test it on the instance where the month selected is Feb(where I'm supposed to get results for the previous Dec),it doesn't return any results.
Could someone maybe help me figure that one out.

Thanks\Regards

Taboka
Title: Re: 2 Months ago date filter
Post by: Taboka on 28 Jan 2008 06:32:57 AM
Hi everyone,
I realised the problem was my math in calculating the previous Dec from a selected month of Feb.The correct filter is therefore
[Recharge Monthly].[Time Month].[Time Month Key]=(if( substring(to_char(?FromDate?),5,2) = 01)
then ((?FromDate? - 89)-1)
else if( substring(to_char(?FromDate?),5,2) = 02)
then (?FromDate? - 90)
else (?FromDate? - 2))
and it works like a charm.

Hope this helps someone.

Cheers
Taboka
Title: Re: 2 Months ago date filter
Post by: nishu85 on 07 Feb 2008 03:40:38 PM
you could have used add_months([date item] , -2 ) for that
Title: Re: 2 Months ago date filter
Post by: COGNOiSe administrator on 08 Feb 2008 02:43:54 PM
Add_months and other add_* functions are great indeed.