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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Current Month vs Last Month

Hi , I have the following expression to obtain Last Month based on the selected Month:

sum({<Month={$(=Month(AddMonths(Max(OrderDate),-1)))}>}Sales)

But, when the selected Month = January, it does not change the year.

The correct result should be December of the past year

Capture2.PNG

Thanks

Labels (1)
1 Solution

Accepted Solutions
girirajsinh
Creator III
Creator III

Try

sum({<Month={$(=Month(AddMonths(Max(OrderDate),-1)))},YearField={$(=Year(AddMonths(Max(OrderDate),-1)))}<>}Sales)

View solution in original post

3 Replies
girirajsinh
Creator III
Creator III

Try

sum({<Month={$(=Month(AddMonths(Max(OrderDate),-1)))},YearField={$(=Year(AddMonths(Max(OrderDate),-1)))}<>}Sales)

MK9885
Master II
Master II

Do you have Master Calendar script in place to deal with dates?

If yes?

Then use

if(InMonth(TempDate, today(),-1), 1, 0) as LastMonthFlag,

In your Master script

And in front end use

sum({<LastMonthFlag={1}>}Sales)

Anonymous
Not applicable
Author

Are the numbers accurate and just the column header wrong?