Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
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.
Highlighted


@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.

Highlighted
Contributor
Contributor

That worked. Thanks Sunny!
Highlighted
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.