Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
mahitham
Creator II
Creator II

Current month vs previous month issue

Hi Experts,

Can any one please help me on below issue.

I have used below expressions for current and previous month kpis

Current:

=Sum(Aggr(Count({<[Month Name]= {'$(=MonthName(Max([Date])))'}, Product = {"*"}-{' '}>} Distinct id), [Month Name],Product))

Previous:

=Sum(Aggr(Count({<[Month Name]= {'$(=MonthName(AddMonths(Max([Date]),-1)))'},Product = {"*"}-{' '}>} Distinct id), [Month Name],Product))


By default its showing the results correctly


default.png


When I have selected april previous kpi changed to zero

selections.png


Please help me on this.


Thanks in advance

4 Replies
ogautier62
Specialist II
Specialist II

Hi,

it's I think because you make a selection

so max(date) is april, and there's notthing selected for max(date) - 1

try with {1      to select all without taking account of selection for month-1

regards

mahitham
Creator II
Creator II
Author

stalwar1

sasiparupudi1

jontydkpi

jyothish8807

Could you please suggest any way to resolve the above issue.

Thanks in advance.

tresesco
MVP
MVP

Try putting the month selection by-pass in set analysis in aggr(), like:

Previous:

=Sum(Aggr({< [Month Name]>} Count({<[Month Name]= {'$(=MonthName(AddMonths(Max([Date]),-1)))'},Product = {"*"}-{' '}>} Distinct id), [Month Name],Product))


jyothish8807
Master II
Master II

Hi Mahitha,

Your expression looks correct to me.

May be try to see the output of "=MonthName(AddMonths(Max([Date]),-1))" or create a variable for max Month name and previous month name and use in the expression.

Else you can try to bypass the monthname field as suggested by tresesco‌.


Br,

KC

Best Regards,
KC