Skip to main content
Announcements
Qlik Community Office Hours, March 20th. Former Talend Community users, ask your questions live. SIGN UP
cancel
Showing results for 
Search instead for 
Did you mean: 
ktdewit1976
Contributor
Contributor

If-statement for Previous 12 Months

In my Master Calendar in my Edit Script I have used the following:

If(Datum <= Today() And Datum >= SetDateYear(Today(), Year(Today())-1), 1, 0) As Last12Months

Now I want to add a similar If-statement for Previous 12 Months. How do I script this (in a similar way as above)?

I am using this to be able to compare data for the last 12 months and the previous 12 months a year earlier. In a bar chart for example.

Labels (3)
13 Replies
pradosh_thakur
Master II
Master II

pick(Match(Month,month(today()),month(addmonth(today(),-1)),month(addmonth(today(),-2)),month(addmonth(today(),-3)),month(addmonth(today(),-4)),month(addmonth(today(),-5)),month(addmonth(today(),-6)),month(addmonth(today(),-7)),month(addmonth(today(),-8,)),month(addmonth(today(),-9)),month(addmonth(today(),-10)),month(addmonth(today(),-11))),1,2,3,4,5,6,7,8,9,10,11,12)

Try the above if month is the dimension . Please check the performance as it contains addmomth() 11 times.

Learning never stops.
sunny_talwar


@pradosh_thakur wrote:
pick(Match(Month,month(today()),month(addmonth(today(),-1)),month(addmonth(today(),-2)),month(addmonth(today(),-3)),month(addmonth(today(),-4)),month(addmonth(today(),-5)),month(addmonth(today(),-6)),month(addmonth(today(),-7)),month(addmonth(today(),-8,)),month(addmonth(today(),-9)),month(addmonth(today(),-10)),month(addmonth(today(),-11))),1,2,3,4,5,6,7,8,9,10,11,12)

Try the above if month is the dimension . Please check the performance as it contains addmomth() 11 times.


You are really complicating it. I don't think we need this.

ktdewit1976
Contributor
Contributor
Author

That worked. Thanks Sunny!
pradosh_thakur
Master II
Master II


@sunny_talwar wrote:


You are really complicating it. I don't think we need this.


Yeah. It's really over complicated.  Just thought too much i guess. I was trying to get jan to the last and didn't think of the simpler solution.  😄 

Learning never stops.