COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: richiearora on 30 Sep 2013 05:54:04 AM

Title: Help with Last Year last Month
Post by: richiearora on 30 Sep 2013 05:54:04 AM
Hi,

I want to build logic in my report where Each month the Data is picked for Previous Month For Example.. Febrauary i would need January And for April i would need March.

I am able to filter them, However problem is with January when it has to be December Previous year.

Could you please help me write the case or if condition for same?
Title: Re: Help with Last Year last Month
Post by: Gopinath on 30 Sep 2013 06:08:22 AM
When your [Date] is '2013-Jan-01'

_add_months([Date], -1)  will give you  '2012-Dec-01'.




Title: Re: Help with Last Year last Month
Post by: richiearora on 30 Sep 2013 06:31:13 AM
Thanks Gopi, However my Measures have the Months as 1,2,3,4.. and So on ..

So that add months concept doesnt work for me
Title: Re: Help with Last Year last Month
Post by: MFGF on 03 Oct 2013 06:52:33 AM
How about:

CASE [Your month item] 
WHEN 2 THEN 1
WHEN 3 THEN 2
WHEN 4 THEN 3
WHEN 5 THEN 4
WHEN 6 THEN 5
WHEN 7 THEN 6
WHEN 8 THEN 7
WHEN 9 THEN 8
WHEN 10 THEN 9
WHEN 11 THEN 10
WHEN 12 THEN 11
WHEN 1 THEN 12
ELSE 0 
END