Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Implement 12 rolling months in in a table ?

Hello,

Currently the table displays data from jan to current month (see fig below)

rolling.png

Is it possible to display data from current month to previous 12 months

  1. i.e  from May 2013 to April 2014 .Want it to be dynamic.(see below)
MayjunJulyAugSepOctNovDecJanFebMarApril
52,85047,80652,82251,11452,81851,11452,81852,81851,11452,81851,11452,818

Any suggestions?

B

1 Solution

Accepted Solutions
swarup_malli
Specialist
Specialist

Try  a creating a flag based on your date field or you could also create a seperate column in the script editor  for rolling months

something like this:

 

IF

(Your_DATE<=date(monthstart(today()),'YYYY-MM-DD') AND Your_DATE >= date(addmonths(monthend(date(today(),'MMM-YYYY')),-12) ,'YYYY-MM-DD'),1,NULL()) as Rolling_flag,
IF(Your_DATE<=date(monthstart(today()),'YYYY-MM-DD') AND Your_DATE>= date(addmonths(monthend(date(today(),'MMM-YYYY')),-12) ,'YYYY-MM-DD'),Your_DATE,NULL())AS ROLLING_DATE,

Hope this helps

SM

View solution in original post

7 Replies
its_anandrjs

Yes yo can make it rolling months refer the below URL for rolling months

Calculating rolling n-period totals, averages or other aggregations

Anonymous
Not applicable
Author

Anand,

I did go through the post, I don't know if it would solve my problem.

I was wondering should I use a variable that holds current month ..then display previous months.

What would be the besgt way to implement the solution, using set analysis or in the script editor

B

Anonymous
Not applicable
Author

Is it possible to load only the previous 12 months ?

its_anandrjs

In the script level you can do like this

Create two variables which is based on the Monthyear because you want rolling 12 months

vPrevMonthYear = Num(AddMonths(MonthYear,-12)) ;

vCurrMonthYear = Num(MonthYear) ;

Then use in script like

Dimension :- Monthyear

I believe it is a sales value you change according to you

Expression :- =Sum({$<MonthYear = {">$(vPrevMonthYear) <=$(vCurrMonthYear)"}>} Sales)

Regards

its_anandrjs

Is rolling back 12 months problem solve if so then mark the thread as Correct or helpful.

Anonymous
Not applicable
Author

Sorry for the late reply,

Do i generate a calendar between  the vPrevMonthYear and vCurrMonthYear ?


swarup_malli
Specialist
Specialist

Try  a creating a flag based on your date field or you could also create a seperate column in the script editor  for rolling months

something like this:

 

IF

(Your_DATE<=date(monthstart(today()),'YYYY-MM-DD') AND Your_DATE >= date(addmonths(monthend(date(today(),'MMM-YYYY')),-12) ,'YYYY-MM-DD'),1,NULL()) as Rolling_flag,
IF(Your_DATE<=date(monthstart(today()),'YYYY-MM-DD') AND Your_DATE>= date(addmonths(monthend(date(today(),'MMM-YYYY')),-12) ,'YYYY-MM-DD'),Your_DATE,NULL())AS ROLLING_DATE,

Hope this helps

SM