Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Highlighted
jenstarr
New Contributor III

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))))))

Tags (1)
1 Solution

Accepted Solutions
chrismarlow
Valued Contributor

Re: set analysis dates <= not working

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

12 Replies
giakoum
Honored Contributor II

Re: set analysis dates <= not working

do you have a sample app for that?

Not applicable

Re: set analysis dates <= not working

Try using single quotes and wrapping the variable in the Date() function. And don't forget a space between the >= / <= groups:

Sum({<Year =, Month = ,Transaction_Date={'>=$(=Date($(vCurrentYearStart))) <=$(=Date($(vCurrentYearDate)))'}>}Invoice_Amount)

jenstarr
New Contributor III

Re: set analysis dates <= not working

Thanks Dirk! 

When I added the $ after the Date($( it returned 0, so this is what it looks like now and I'm still getting the same results where it is not picking up the last day of the month.

Transaction_Date={'>=$(=Date((vCurrentYearStart))) <=$(=Date((vCurrentYearDate)))'}

Thanks for you help.  I really appreciate it.

Jen

neetha_p
Honored Contributor

Re: set analysis dates <= not working

Hi Jen,

Try:

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

Regards

Neetha

jenstarr
New Contributor III

Re: set analysis dates <= not working

Thank you Neetha!

Just tried and it is still not picking up the last day of the month.

menta
Contributor

Re: set analysis dates <= not working

put your formula into a chart with no name in expression and verify which part doesn't work

jenstarr
New Contributor III

Re: set analysis dates <= not working

It's the <= that does not work.  It is ignoring the last day of the month, so the <= is behaving like a < .  If I change the variable vCurrentYearDate to be the 2/1/15, and use the <= it will pick up 1/31/15 data and not 2/1/15 data.  As it is right now  vCurrentYearDate = 1/31/15 and the last date showing in the range is 1/30/15 not 1/31/15 as I would expect.

neetha_p
Honored Contributor

Re: set analysis dates <= not working

Hi Jen,

Try:

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

Regards

Neetha

chrismarlow
Valued Contributor

Re: set analysis dates <= not working

I had an issue once where I had used MonthEnd to create a date & a join failed as it also included the timestamp (to give last millisecond of the actual day).

Might your transaction dates actually have a time on them & therefore be after date is it is calculating as 1/31/15 00:00:00?