Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
sdyankov
Contributor
Contributor

Info for month -1 and year -1

Hey lads,

i'm in a roadblock with the following thing.

I want to make an analysis of the same data as of today, month -1 and year -1.

The data has columns Year = 2017,2018.... and Month =1,2,3,.....

What i was thinking of doing is to create those variables

vCurrentMonth=month(today())

vPreviousMonth=month(today())-1

vCurrentYear=year(today))

vCurrentYear=year(today))-1

 

And respectfully use the logic 

Current month = sum({$<[Month]={vCurrentMonth},[Year]={vCurrentYear}>}[ThingToSum])

Previous month = sum({$<[Month]={vPreviousMonth},[Year]={vCurrentYear}>}[ThingToSum])

Previous year = sum({$<[Year]={vPreviousYear},[Month]={vCurrentMonth}>}[ThingToSum])

 

Naturally, it aint working 🙂

 

Any tips?

 

Thx!

2 Replies
tresesco
MVP
MVP

Try expanding your variables with $ like:

sum({$<[Month]={$(vCurrentMonth)},[Year]={$(vCurrentYear)}>}[ThingToSum])

sdyankov
Contributor
Contributor
Author

for some reason it does not work with the variables.

I've tested the variables in text boxes and they provide the accurate figures for the month number and year number, but when part of the expression they give 0. If i type manually the number of the month, it all works fine