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: 
QS_
Contributor III
Contributor III

Calculating difference between the KPIs for current/selected month and the previous month

I'm trying to use set analysis to  calculate the different in KPI between current/selected month and the previous month. 

For e.g. if July 2023 is selected in the Date Filter, the KPI visual should display the total sales and the difference of Sum of July 2023 sales and June 2023 sales.

Labels (2)
1 Solution

Accepted Solutions
QS_
Contributor III
Contributor III
Author

Thank you, Anat, for sharing the link. I figured out what I wanted. I used the expression below.

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

The dashboard includes a month filter as well. When there are no selections, it should give me the value for the sum of the current month's amount minus the sum of the previous month's amount. Bad it gives nulls when a selection is made.

I made a small modification in the identifier and that fixed the issue.

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

Now I can see the difference in the sum of amount between the selected month and its previous month.

View solution in original post

2 Replies
anat
Master
Master

here is the wonderful material for MoM and YoY calculation.

https://community.qlik.com/t5/QlikView-Documents/YTQ-QTD-MTD-and-WTD/ta-p/1489245

 

QS_
Contributor III
Contributor III
Author

Thank you, Anat, for sharing the link. I figured out what I wanted. I used the expression below.

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

The dashboard includes a month filter as well. When there are no selections, it should give me the value for the sum of the current month's amount minus the sum of the previous month's amount. Bad it gives nulls when a selection is made.

I made a small modification in the identifier and that fixed the issue.

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

Now I can see the difference in the sum of amount between the selected month and its previous month.