Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Pomna
Creator III
Creator III

current year last month

I need help with my code which is  as follows. I need to change 2019 and Oct so that it is not hard coded so that I will not have to go in every month to change the code. Thanks

Sum({$<[Work Date.autoCalendar.Year] = {'2019'}
,[Work Date.autoCalendar.Month] = {'Oct'}
,[IS.Activity Type] = {[Enhancing]}
,[Supported Location] =- {'04'}>}Hours)

1 Solution

Accepted Solutions
yassinemhadhbi
Creator II
Creator II

i hope this works

Sum({$<[Work Date.autoCalendar.Year] = {'$(=year(today()))'}
,[Work Date.autoCalendar.Month] = {'$(=month(AddMonths(Today(),-1)))'}
,[IS.Activity Type] = {[Enhancing]}
,[Supported Location] =- {'04'}>}Hours)

and it should works to be honest hh 

 
 
Best Regards
Yassine Mhadhbi

View solution in original post

10 Replies
yassinemhadhbi
Creator II
Creator II

you can change 2019 with $(=year(today()))

and the month -1 with  $(=month(today())-1)

Best Regards
Yassine Mhadhbi
Pomna
Creator III
Creator III
Author

Thanks for the response but it does not work

yassinemhadhbi
Creator II
Creator II

to check whether your expression is fine or not, try to put it in text object 

Best Regards
Yassine Mhadhbi
Pomna
Creator III
Creator III
Author

My code works alright but I want to make it dynamic. I do not want it hard coded like it is so that I do not have to go in each month to make changes. The suggestions above do not work. any other suggestions will be appreciated

yassinemhadhbi
Creator II
Creator II

can you attach the QVW file ?

Best Regards
Yassine Mhadhbi
Pomna
Creator III
Creator III
Author

Sorry its sensitive data not allowed to share

yassinemhadhbi
Creator II
Creator II

i hope this works

Sum({$<[Work Date.autoCalendar.Year] = {'$(=year(today()))'}
,[Work Date.autoCalendar.Month] = {'$(=month(AddMonths(Today(),-1)))'}
,[IS.Activity Type] = {[Enhancing]}
,[Supported Location] =- {'04'}>}Hours)

and it should works to be honest hh 

 
 
Best Regards
Yassine Mhadhbi
Pomna
Creator III
Creator III
Author

Thank you the code worked. But I have one more worry.  Since my chart is supposed to show metrics for previous month how do I tweak the code to show metrics for December 2019 when we are in January 2020?

yassinemhadhbi
Creator II
Creator II

there will be no problem since the function addmonth(today(),-1) will return 1/12/2019 when it is on 1/1/2020 

so there's no problem

Best Regards
Yassine Mhadhbi