Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
ashis
Creator III
Creator III

Current month and previous month values are getting same

Hi ,

In my data model, I have month and year combination field as

Year(Date) * 12 + num(Month(Date)) as [Month Counter], I want to calculate current month vs previous month values. So I have two expression as

current month
avg({<[Month Counter]={'$(=MAX([Month Counter]))'}>} xxx)

previous month


avg({<[Month Counter]={'$(vPreviousMonthCounter)'}>} xxx)

vPreviousMonthCounter as

vPreviousMonthCounter=max([Month Counter]) -1

Both the values for current and previous month are getting same, however it is not correct . Is my expression wrong or do I need to use it in different way.

Please suggest.

5 Replies
shiveshsingh
Master
Master

What is the value of =MAX([Month Counter] and vPreviousMonthCounter

ashis
Creator III
Creator III
Author

MAX([Month Counter] returns 24219 , that is March and

vPreviousMonthCounter returns 24218 that is Feb.

poojashribanger
Creator II
Creator II

you can use max(month) and max(month)-1 as well

poojashribanger
Creator II
Creator II

you can use this expression for previous month

sum({<DT_LCL={"$(=date(max(DT_LCL)-1))"}>}CHRN_CT)

you can use this for max(month)

sum({<DT_LCL={"$(=date(max(DT_LCL)))"}>}CHRN_CT)

shiveshsingh
Master
Master

Try in double quotes once.

avg({<[Month Counter]={"$(=MAX([Month Counter]))"}>} xxx)