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

Last year day comparison

Hello,

I'm looking for a possibility to compare the current selected day values (e.g. sales )to the last years day (sales).

Because of some sepcial demands I have already a time table with the date_of_day and a second column last_year_day.

How can I build such a function in a metric expression ?

I guess set analysis, but I can't get it working.

Thank you !

6 Replies
pover
Partner - Master
Partner - Master

What type of filter does the user select?  Calendar dates? Months? Days in numbers?

Karl

Not applicable
Author

It's a calendar date and the last_year_date column is also type date.

pover
Partner - Master
Partner - Master

It's easier if you have separate year, month, day columns, but the following set analysis worked for me when the filter was a complete calendar date.

sum({$<Date={$(=chr(39) & concat(distinct makedate(year(Date)-1,month(Date),day(Date)),chr(39)&','&chr(39))&chr(39))}>} Sales)

The chr(39) are single quotes around the dates.

Karl

Not applicable
Author

Thanks a lot !

But would it also be possible to use a different already created last year date in a separate table colmun last_year_day ?

pover
Partner - Master
Partner - Master

I had a feeling you might ask that.  It should work if you adjust the expression to something like:

sum({$<Date={$(=chr(39) & concat(distinct last_year_day,chr(39)&','&chr(39))&chr(39))}>} Sales)

Not applicable
Author

How can I compare the below dates?

1/5/2012 Thursday

to

1/6//2012 Thursday