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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Jérôme5625
Creator
Creator

Set analysis issue / Count of the defect the last month

Hello,
a simple question for those who are more experienced than me. I would like to display the sum of the defects of the previous month chosen. The sum of defects of the selected month works but as soon as I add "-1" for the previous month, the result becomes 0. I think this must be due to a syntax problem.

Can you help me?

 

Set analysis: Count({$<[Data.Mois]={$(=Only([Data.Mois])-1)}>}[Data._kizeo_id]) 

Labels (1)
6 Replies
BrunPierre
Partner - Master II
Partner - Master II

Count({$<[Data.Mois]={"$(=Only([Data.Mois])-1)"}>}[Data._kizeo_id]) 

vinieme12
Champion III
Champion III

is Month a Text field or a Numeric field ?

Also simply  substracting  MonthNumber  -1 will fail if you select January which will be 1-1 = 0

You should actually be using the actual Date field to refer previous month

 

Latest/Selected Month

Count({<Datefield={">=$(=Date(Monthstart(Max(Datefield)))<=$(=Date(Max(Datefield)))"}>}[Data._kizeo_id]) 

 

Previous Month

Count({<Datefield={">=$(=Date(Monthstart(Max(Datefield),-1)))<=$(=Date(Monthend(Max(Datefield),-1)))"}>}[Data._kizeo_id]) 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Jérôme5625
Creator
Creator
Author

Hi Vinieme12, 

Thanks for your feedback.

I tested : Count({<Datefield={">=$(=Date(Monthstart(Max(Datefield),-1)))<=$(=Date(Monthend(Max(Datefield),-1)))"}>}[Data._kizeo_id]) 

but the result is always the current month and not the previous month.
Attached is the screenshot which shows that the months M-1, M -2 and M-3 are always identical to the selected month.
Thanks in advance for your help

vinieme12
Champion III
Champion III

Can you post the exact expression you used? A full snapshot of the expression editor 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Jérôme5625
Creator
Creator
Author

Attached the snapshot of the expression editor for the last month.

Thanks for advance for your help

vinieme12
Champion III
Champion III

You need to replace Datefield with THE ACTUAL DATE FIELD 

Just like you have Data.Mois  you must have a field that has date values! Use that field 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.