Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
MadhuriReddy
Contributor III
Contributor III

Error in KPI (Current Quarter and Previous Quarter)

Hello QlikCommunity,

We have KPI to show difference between Current quarter and Previous quarter. 

The expression for KPI

"sum({<QuarterYearNum={"$(=max(QuarterYearNum))"}>}[Units])

-
sum({1<QuarterYearNum={"$(=max(QuarterYearNum)-1)"}>}[Units])"

If I select any filter "company or  Business area or Country" then it's not comparing with the selected filter's previous quarter value, instead it is taking total previous quarters value with the selected current quarters filter value.

example:

Current quarter value for selected filter:100

Previous quarter value for selected filter:80

Total Previous Quarter value : 500

KPI Should be:20

but it is showing:400

Where is miss the logic........

Please help me out.

 

 

 

 

Labels (4)
1 Solution

Accepted Solutions
MadhuriReddy
Contributor III
Contributor III
Author

I got solution

I have exclude the "quarteryear" selection

sum({<QuarterYearNum={"$(=max(QuarterYearNum))"}>}[Units])

-
sum({1<QuarterYearNum={"$(=max(QuarterYearNum)-1)",Quarteryear= }>}[Units])"

View solution in original post

7 Replies
Qrishna
Master
Master

Pls try This:

= sum({$<QuarterYearNum={"$(=max(QuarterYearNum))"}>}[Sales]) -
   sum({$<QuarterYearNum={"$(=max(QuarterYearNum)-1)"}>}[Sales])

'$' - in Set expressions takes current selections
'1' - in set expressions takes entirety. i.e ignores any selections made

MadhuriReddy
Contributor III
Contributor III
Author

Hi Krishna,

Thanks for your response. If I remove '1' from the set expression, then it takes only previous quarter value not showing the difference between current quarter and previous quarter.

Ex: The current quarter is Q3.If we click on Q2(any previous quarter), then it is showing only Q2 value instead of difference.

Qrishna
Master
Master

Try this expression:

= sum({$<QuarterYearNum={"$(=max(QuarterYearNum))"}>}[Sales]) -
   sum({$<QuarterYearNum={"$(=max(QuarterYearNum)-1)"}>}[Sales])

Qrishna
Master
Master

Ex: The current quarter is Q3.If we click on Q2(any previous quarter), then it is showing only Q2 value instead of difference.

 

When you have max(QuarterYearNum) in the expression, it calculates the max value for QuarterYearNum, no matter what quarter you slect 

Qrishna
Master
Master

if you want more clearer solution, pls provide a mock up data.

MadhuriReddy
Contributor III
Contributor III
Author

Hi Krishna,

Thanks for response. I got solution.

MadhuriReddy
Contributor III
Contributor III
Author

I got solution

I have exclude the "quarteryear" selection

sum({<QuarterYearNum={"$(=max(QuarterYearNum))"}>}[Units])

-
sum({1<QuarterYearNum={"$(=max(QuarterYearNum)-1)",Quarteryear= }>}[Units])"