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: 
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.