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

Announcements
Note: You may notice some temporary visual or styling issues in the Community. Our vendor is actively investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Same date last year/quarter

what expression would I use to find the same date, but last year or quarter? My best guess would be

Today()-quarter

Today()-year

1 Solution

Accepted Solutions
Michiel_QV_Fan
Specialist
Specialist

inquartertodate (Feedback.TempDate,addmonths(today(), -3),0) *-1 as Feedback.LQTDFlag

View solution in original post

8 Replies
Michiel_QV_Fan
Specialist
Specialist

addyears(today(), -1) will give you the previous year date

addyear(today(), -1, ceil(month(today()/3) will give you year and quarter

Not applicable
Author

thanks Michiel

how about just last quarter though, instead of last quarter and year?

Michiel_QV_Fan
Specialist
Specialist

ceil(num(month(addyears(today(), -1))/3) as Quater_lastYear

Not applicable
Author

So currently I have a line in my master calendar which flags if a date is in the last quarter to date.

inquartertodate (Feedback.TempDate,'2013-11-14',0) *-1 as Feedback.LQTDFlag

Obviously the problem with this is that I have to change the date manually each day. I tried insert your suggestion in place of '2013-11-14' (as per below) but i got an error

inquartertodate (Feedback.TempDate,ceil(num(month(addyears(today(), -1))/3),0) *-1 as Feedback.LQTDFlag

what am I doing wrong?

Michiel_QV_Fan
Specialist
Specialist

You have a calculated quarter in the basedate. This should be a date.

Try this:

inquartertodate (Feedback.TempDate,today(),0) *-1 as Feedback.LQTDFlag

Not applicable
Author

That gives me the current quarter to date unfortunately. I actually need the last quarter to date

Michiel_QV_Fan
Specialist
Specialist

inquartertodate (Feedback.TempDate,addmonths(today(), -3),0) *-1 as Feedback.LQTDFlag

Not applicable
Author

PERFECT! thanks