Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Get Current month and previous month

I need help...

I want to calculate current month and previous month. Eg. Suppose all data is selected then values show current month(May) data and previous month(April) data, and if user click on April month filter then variable need to show current month as April and previous month as March. Hope you understand the requirement.

2 Replies
kfoudhaily
Partner - Creator III
Partner - Creator III

your requirement is clear and classic but this should be done in restitution part inside expressions depending what you need to calculate using set analysis

please have a look at this: Set Analysis Current Month vs Previous Month

else precise your data and what you need to calculate, sum, count...

QlikView Qlik Sense consultant
vikasmahajan

create this variable on load script:

et vPriorMonth  = '=month(addmonths(max(GasDay),-1))';

let vPriorMonthYear = '=Year(addmonths(max(GasDay),-1))';

Then I used this for finding the last month charges

=SUM({<Year={'$(vPriorMonthYear)'},Month={'$(vPriorMonth)'}>} SalesValue)

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.