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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
sunil-kumar5
Creator II
Creator II

Current Month and Previous Month Product Count on KPI

Hi Community,

I want to display current month distinct count vs previous month distinct count of Product ID on KPI, Please help

Sample Date:

Product IDInstallation Date
681701-02-2017
493901-02-2018
542301-02-2019
230301-02-2020
322601-02-2017
306401-02-2018
354708-07-2020
786208-07-2020
603001-02-2017
781001-02-2018
580001-02-2019
439008-07-2020
780801-02-2017
583501-02-2018
629301-02-2019
701908-15-2020
798708-02-2020

 

Thanks

3 Replies
tresesco
MVP
MVP

If you have a month field, it would be something like:

Count(Distinct {<Month={'$(=Month(Today()))'}>} [Product ID] )   //Current month

Count(Distinct {<Month={'$(=Month(Addmonths(Today(),-1)))'}>} [Product ID] )   //Previous month

If you have only date field(which is generally not a good data model I would say), try like:

Count(Distinct {<[Installation Date]={"=Month(today())=Month([Installation Date])"}>} [Product ID] )   //Current month

Count(Distinct {<[Installation Date]={"=Month(Addmonths(today(),-1))=Month([Installation Date])"}>} [Product ID] )   //Current month

sunil-kumar5
Creator II
Creator II
Author

Hi Tresesco, Thanks for your reply!!

I have a month field as well. I have tried both the way you suggest and I am getting the desired result as well but the only problem is that I have to select current year to get the result otherwise everything is fine. 

Is it possible if I dont select year filter to current year and get the desired result?

Thanks

tresesco
MVP
MVP

There is a problem of notification. I didn't realize that you replied.

Try something like:

Count(Distinct {<Year={'$(=Year(Today()))'}, Month={'$(=Month(Today()))'}>} [Product ID] )