COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: actcognosuser on 06 May 2010 08:13:45 AM

Title: MTD ,YTD Calculations
Post by: actcognosuser on 06 May 2010 08:13:45 AM
Hi All,
            How to calculate MTD ,YTD ,Timeline to Date(time betwn start and end o project) without displaying daily details.

I have a relational source.In croostab I pulled in current date.When I use the week(current_date) and do a aggregate .It gives me the same value as the current date instead of weekly count.same happens with MTD and timeline to date.

In the query i have a filter to pull the current date only.If i remove that and use current date as dataitem also..I get the same results.

Please advise.
Title: Re: MTD ,YTD Calculations
Post by: MFGF on 06 May 2010 08:33:14 AM
With a relational package, you will most likely need a separate query each for MTD, YTD and TLTD, with each query having a specific filter for the required time period.  These can then be joined and used in your main query.

Regards,

MF.
Title: Re: MTD ,YTD Calculations
Post by: actcognosuser on 06 May 2010 08:41:25 AM
Hi MFGF,
                Would I need to Union all these queries.I have 8-10 measures to report on.I would have to duplicate them 3 times,and  get the MTD,YTD and timeline values.could it be made simpler?


Title: Re: MTD ,YTD Calculations
Post by: MFGF on 06 May 2010 09:35:27 AM
I'd expect the queries to be joined rather that UNIONED.
Title: Re: MTD ,YTD Calculations
Post by: actcognosuser on 06 May 2010 09:59:46 AM
Do i need to create a dummy data item to join them?
Title: Re: MTD ,YTD Calculations
Post by: actcognosuser on 06 May 2010 10:11:12 AM
Hi MFGF,
                  I tried to join on a constant and also on country code.The count is a lot higher
than it is supposed to be.Cant get the union to work.Says set operation not compatible.
Check the order.Everything is right.Guessing there must be something to do with the aggregation properties since i have 10 measures.
Title: Re: MTD ,YTD Calculations
Post by: ksvchowdary on 30 Jun 2010 05:18:07 PM
[date] between _add_days(current_date,((_day_of_year((current_date)-1)*-1)) and current_date)

I Hhope it helps you.
Thanks ,
Sri Kalyanapu.
Title: Re: MTD ,YTD Calculations
Post by: mvjcognos on 13 Jul 2010 05:25:13 AM

mtd: date between first_of_month(date) and date
howevr u want current month from day 1 to to_date

if u want previous month 1st to last day then

previous mtd: date between first_of_month(add_months(date,-1)) and last_day(add_months(date,-1))