8 Replies Latest reply: Aug 17, 2012 5:25 AM by Ananth Raj

# Rolling 12 months

Hi all.

I have a code that is supposed to show rolling 12 months based on selected period.

example. Choose 201206 and the line graph should display from 201206 and 12 months back.

The formula:

sum({\$<KVGruppe2={'%Rent'}>}{<Period ={">=\$(=addmonths(Max(Period), -12)) <=\$(=addmonths(Max(Period), 0,  'YYYYMM'))"} >}OutOfOuterLimit)

But when I try this it goes all the way back to 200901.

I tried to set dimmension to =if(period <StartPeriod, period)

StartPeriod is allways period -12.

Anyone see why?

BR

Dan

Edited: Added an example

• ###### Re: Rolling 12 months

it'll be better if you will send small sample app

• ###### Re: Rolling 12 months

Hi

I have created a test that shows what I am trying.

BR

Dan

• ###### Re: Rolling 12 months

Try the Sample App..

Hope iit helps!!

• ###### Re: Rolling 12 months

Hi Rajni

I tried to alter my test app to suit your sample. Created two variables, but I still do not get it to do as needed.

I get it to start at my selected period, but it does not end at -12 months. It goes all the way back.

Your code and my code(the original one) seems to do the same.

Dan

• ###### Re: Rolling 12 months

the problem is ur max(period) is giving out the result 201009, which is assumed as number of date so when i change it into date it gives 04-05-2450 as Output,

date(max(Period),'DD-MM-YYYY') returns 04-05-2450

AddMonths(max(Period),-1) returns  04-04-2450

you should take some other field for selection

Hope it helps!!

• ###### Re: Rolling 12 months

or you can use makedate(split the period field in year, month,day)

• ###### Re: Rolling 12 months

Hi dan,

Your Code and Rajni code is same but

rajni code that dimension is date format and your code is string format first change that code string to date then u can try, it works

• ###### Re: Rolling 12 months

Hi,

Please find the attached file.

Regards,

Som