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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

YTD addmonth query

Hi There, i am so close to solving this, please can someone help me with this expression, i have a simple dashboard where i need to compare 2 years Year To Date, it is a count of members this time last year:

Count ({< TransactionDate={">=$(=addmonths(today(),-12))"}>} distinct MemberNo)

TransactionDate = YYYYMMDD

It is bringing back all the values for last year instead of only this time last year.

Thanks

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

For YTD, don't you want "<=" 12 months ago? And you might need to format the result for comparison. And you'll need to give it a starting date of the first of that year as well. So my first guess is this:

count({<TransactionDate={">=$(=date(yearstart(today(),-1),'YYYYMMDD')) <=$(=date(addmonths(today(),-12),'YYYYMMDD'))"}>} distinct MemberNo)

View solution in original post

2 Replies
johnw
Champion III
Champion III

For YTD, don't you want "<=" 12 months ago? And you might need to format the result for comparison. And you'll need to give it a starting date of the first of that year as well. So my first guess is this:

count({<TransactionDate={">=$(=date(yearstart(today(),-1),'YYYYMMDD')) <=$(=date(addmonths(today(),-12),'YYYYMMDD'))"}>} distinct MemberNo)

Not applicable
Author

Hi John, Thanks, that worked perfectly, for some reason i had to change the -12 to -13 to get the exact YTD comparison for last year which gives me exactly what i need. Much appreciated.