Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
NickHoff
Specialist
Specialist

Previous 4 weeks going back one week.

Currently I have my week start on Sunday.

I'd like for my report to go back to the previous week start from the current date and count the previous 4 weeks from that date with the week starting on Sunday.

Currently I have my previous 4 weeks defined as

Date(Num(Date(Today(),'DD/MM/YYYY')-28)) AS Previous4Weeks,

if((TempDate <= today() and TempDate >= weekstart(today()-28)),1,0) as Previous4WeeksIND,

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Date(WeekStart(Today(), 0, 6) - 35) as Previous4Weeks,

If((Num(TempDate) <= Num(WeekStart(Today(), 0, 6) - 7) and

     Num(TempDate) >= Date(WeekStart(Today(), 0, 6) - 35)), 1, 0) as Previous4WeeksIND

View solution in original post

5 Replies
sunny_talwar

when you say previous week start, do you mean this: if today is 7/14/2015 -> Previous Week Start would be 7/12/2015 or 7/05/2015???

NickHoff
Specialist
Specialist
Author

Previous Week start would be 7/5/2015 and it would go back 4 weeks

sunny_talwar

Try this:

Date(WeekStart(Today(), 0, 6) - 35) as Previous4Weeks,

If((Num(TempDate) <= Num(WeekStart(Today(), 0, 6) - 7) and

     Num(TempDate) >= Date(WeekStart(Today(), 0, 6) - 35)), 1, 0) as Previous4WeeksIND

NickHoff
Specialist
Specialist
Author

Worked like a charm, I didn't think about going back 35 days instead of 28.  Thank you, Sunindia.

sunny_talwar

Not a problem

I am glad I was able to help.

Best,

Sunny