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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
yaniv_MOJ
Contributor II
Contributor II

How to calculate a measure between two dates

Hello everyone, I am trying to present a number of requests in the graph from 2020 to date, and not for the whole year and not so successful, this is the formula I use :

Count( { $< [Open_Date.autoCalendar.Year]={'$(=Year(Today())-1)','$(=Year(Today()))'}>}[ID] )

 

, I would appreciate help

Labels (1)
8 Replies
stevejoyce
Specialist II
Specialist II

How about 

{>'$(=Year(Today())-1)' and <'$(=Year(Today()))'}

yaniv_MOJ
Contributor II
Contributor II
Author

My problem is not in the syntax of the formula, but in the fact that I get results for the entire current year including months such as November, December, etc., I want to get results by the current month. I have attached an example
Thanks

yaniv_MOJ_0-1629377350666.png

 

stevejoyce
Specialist II
Specialist II

Oh I see.  Then can you add date less then today.  or month-year less then monthname(today())

Count( { $< [Open_Date.autoCalendar.Year]={>'$(=Year(Today())-1)'}, [Open_Date.autoCalendar.Date]={<'$(=Today())'}>}[ID] )

yaniv_MOJ
Contributor II
Contributor II
Author

Thanks for the answer, I copied the attached formula, but unfortunately it does not work :(, the syntax is incorrect

anthonyj
Creator III
Creator III

Hi,

Something I just picked up this morning when I was looking into a similar question is that the result of using the autoCalendar.Year column gives you the 44197 (or 01/01/2021). This doesn't resolve to 2021 which is what year(today()) will give you. Interesting it works if you use set analysis with an equals sign but it doesn't appear to work with a less than or greater than sign.

I get around this by using the date in the set analysis:

Count( { $< [Open_Date.autoCalendar.Date]={">=$(=yearstart(today(0),-1,1))<=$(=monthend(today(0)))"}>}[ID] )

If you want to cut it off at the end of last month you can shift the monthend function like this: monthend(today(0),-1)

Regards

Anthony

yaniv_MOJ
Contributor II
Contributor II
Author

It works !!!!
Anthony Thank you very much

anthonyj
Creator III
Creator III

Hi @yaniv_MOJ ,

I'm happy to have been able to help. 

Could you mark the post as solved to assist in any future searches for the same question.

Thank You

Anthony

stevejoyce
Specialist II
Specialist II

Yes sorry @yaniv_MOJ , this is the correct syntax:

Count( { $< [Open_Date.autoCalendar.Year]={">$(=Year(Today())-1)"}, [Open_Date.autoCalendar.Date]={"<$(=Today())"}>}[ID]