Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
arulsettu
Master III
Master III

current month vs last year same month

hi

i am showing current month vs last year same month

this code showing current month vs last month

sum({<FiscalPeriod={$(=max(Num(Month(Date(Today()))))),$(=max(Num(Month(Date(Today())))-1))}>}Customer)

i want to make sure the above code is correct and how to get last year same month

thanks

8 Replies
arulsettu
Master III
Master III
Author

any help?

geert_gelade
Creator
Creator

For this kind of comparisons, I always calculate a "MonthID" in the script:

(num(Year(Date))-1)*12 + Month(Date) as MonthID

In your expressions you can use afterwards:

Sum({$<MonthID = {$(=Max(MonthID)-12)} >} Amount) for month in previous year

Sum({$<MonthID = {$(=Max(MonthID))} >} Amount) for month in current year

Hope this helps

rubenmarin

That expression executed today will show the sum of the 'Customer' field for Fiscal Period '9' and '8'

Can you upload a sample?

arulsettu
Master III
Master III
Author

here it is

rubenmarin

Following your expression for month vs month, year vs year should be:

sum({<FiscalYear={$(=max(Num(Year(Date(Today())))-1)), $(=max(Num(Year(Date(Today())))))}, FiscalPeriod={$(=max(Num(Month(Date(Today())))))}>}Customer)

arulsettu
Master III
Master III
Author

if i want to display current month and last year month in two charts how to split the code?

thanks

arulsettu
Master III
Master III
Author

it showing current month only

rubenmarin

I'm not sure to understand the requirements.

I made some graphs in attached doc. Hope one of those is what you're searching