Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

8 Replies
Not applicable
Author

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

Anonymous
Not applicable
Author

Hi

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

BR

Dan

rajni_batra
Specialist
Specialist

Try the Sample App..

Hope iit helps!!

Anonymous
Not applicable
Author

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

rajni_batra
Specialist
Specialist

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!!

rajni_batra
Specialist
Specialist

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

somenathroy
Creator III
Creator III

Hi,

Please find the attached file.

Regards,

Som

Not applicable
Author

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