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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Syntax for set analysis with dates

Good afternoon,

In a chart, I use expression

count({<JJJJ.MM={"$(KeyDate)"}>}distinct(EmployeeNr))

where I let the user enter the KeyDate (say 2015.12) via an InputBox. So far, so good. Now how can I build expressions for the previous years i.e. 2014.12, 2013.12, etc? Somehow I don´t get the syntax right...

Thanks in advance

10 Replies
rubenmarin

Maybe using the JJJ.MM string and I had another typo: remove the extra ')' in date# function, it should be:

count({<JJJJ.MM={"$(=date(addmonths(date#('$(KeyDate)','YYYY.MM'),-12),'YYYY.MM')"}>}distinct EmployeeNr)


Or using AddYears():

count({<JJJJ.MM={"$(=date(AddYears(date#('$(KeyDate)','YYYY.MM'),-1),'YYYY.MM')"}>}distinct EmployeeNr)


Not tested, if you can upload a sample I can try with real data.