Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Read about Qlik’s Response to COVID-19 Read the Letter, Join the Group.
Highlighted
Contributor 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
Highlighted
Honored Contributor

Re: Current month and previous month values are getting same

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

Highlighted
Contributor III

Re: Current month and previous month values are getting same

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

vPreviousMonthCounter returns 24218 that is Feb.

Highlighted
Contributor II

Re: Current month and previous month values are getting same

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

Highlighted
Contributor II

Re: Current month and previous month values are getting same

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)

Highlighted
Honored Contributor

Re: Current month and previous month values are getting same

Try in double quotes once.

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