Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
roryan
Contributor
Contributor

handling variables date

total value, calculated by current month plus 12 previous months.

I do not know how to do that calculation or variable so that the total of the 12 months is delivered, especially when the months pass to the previous year.
your help please

roryan_0-1602609424372.png

 

2 Replies
edwin
Master II
Master II

there are two ways of doing this, one is by a bridge which is a longer conversation.  another simpler one is by variable which you have alluded to.

in your calendar add a month field
MONTH= monthstart(date)

create a variable vPRIORMONTHS = '>=' & addmonths(Month,-1) & '<=' & addmonths(Month,-12)

add this variable to a text box to test it it should show something like

>=1/1/2019<=2/1/2019

and then in your expression where you sum (or whatever) your measure:
=sum({<Month={"$(vPRIORMONTHS )"}>} SomeMeasure)

Brett_Bleess
Former Employee
Former Employee

The following Design Blog posts may be helpful:

https://community.qlik.com/t5/Qlik-Design-Blog/A-Primer-on-Set-Analysis/ba-p/1468344

https://community.qlik.com/t5/Qlik-Design-Blog/Set-Analysis-in-the-Aggr-function/ba-p/1463822

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.