Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Uladzislau_H
New Contributor II

Compare selected month and previous month data

Hi! I have one problem, and it makes me crazy! 

I need to compare the selected month and previous month data. For first, I need to get these data. I have tried to  get the sum of logged hours by these expressions (Moth_L this is a date):

Sum({$<Month_L = {$(=Max(Month_L) – 1)}>}  Log_Hours) - for previous month

OR

Sum({<Month_L = {">=$(=Date(MonthStart(Max(MonthYear),-1),'MMM-YY'))<=$(=Date(MonthStart(Max(MonthYear),-1),'MMM-YY'))"}>} Log_Hours)

and a few other expressions

But they return 0. 

I think that's because I have selected Month_L in the filter. And when have added Month_L in the expression like an exception:

sum({$<Month_L = {$(=Max(Month_L)-1)}, Month_L=>}  Log_Hours)

And I get the sum working hours for all months. 


So, how can I get the sum of hours by the previous month for comparing with the selected month? 

p.s. I tried to use these sources:

https://community.qlik.com/t5/New-to-QlikView/Comparing-Current-Month-and-Previous-Month-Sales/m-p/5...

https://aftersync.com/blog/the-magic-of-set-analysis-point-in-time-reporting



1 Solution

Accepted Solutions
Uladzislau_H
New Contributor II

Re: Compare selected month and previous month data

This expressions is correct: 

Previous month:

Sum({<Log_Month = {">=$(=MonthStart(AddMonths(Max(Log_Month), -1)))<=$(=MonthEnd(AddMonths(Max(Log_Month), -1)))"}>} Log_Hours)  

Selected month:

Sum({< Log_Month = {">=$(=MonthStart(Max(Log_Month)))<=$(=MonthEnd(Max(Log_Month)))"}>} Log_Hours))

 

View solution in original post

1 Reply
Uladzislau_H
New Contributor II

Re: Compare selected month and previous month data

This expressions is correct: 

Previous month:

Sum({<Log_Month = {">=$(=MonthStart(AddMonths(Max(Log_Month), -1)))<=$(=MonthEnd(AddMonths(Max(Log_Month), -1)))"}>} Log_Hours)  

Selected month:

Sum({< Log_Month = {">=$(=MonthStart(Max(Log_Month)))<=$(=MonthEnd(Max(Log_Month)))"}>} Log_Hours))

 

View solution in original post