Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

set analysis dates <= not working

I'm having difficulty making the <= vCurrentYearDate work in my set analysis.  The variable, vCurrentYearDate gives me the last months prior month end if a month year selection is not made.  The variable is working and gives me the correct date, which is the last day of the month, however the set analysis is not giving me the data for the last day of the month.  It is treating it like a < not a <=.  I have removed all time stamps from the data.  If I change the variable to be the first day of the next month, I can get the last day of the month, but I would like to figure out why the <= is not working properly with this set analysis.

Thanks so much!

Jen

sum({<Year =, Month = ,Transaction_Date={">=$(=(vCurrentYearStart))<=$(=(vCurrentYearDate))"}>}Invoice_Amount)

vCurrentYearDate = date(if(getselectedcount(Year)<>1 and getselectedcount(Month)<>1, date(Monthend(AddMonths(max(Transaction_Date),-1))), date(Monthend((max(Transaction_Date))))))

12 Replies
menta
Partner - Creator II
Partner - Creator II

to solve the problem you can use floor

floor(date(Monthend(AddMonths(max(Transaction_Date),-1)))), Floor(date(Monthend((max(Transaction_Date)))))))

Anonymous
Not applicable
Author

Thank you Christopher!  Yes, it looks like the time stamp is the issue. I put Date(Transaction_Date) as Transaction_Date in my script, which I thought would remove the time from the date. Also, I  SET TimestampFormat='M/D/YYYY' in the script as well.  Is there a better way to remove the time from the date when loading the data?

chrismarlow
Specialist II
Specialist II

I think Carlo's floor would do it, but wrap it around your Transaction_Date (that you might need to cast back into being a date).