Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
lucasdavis500
Creator III
Creator III

Returning last x weeks/days - set analysis

How can I always return the last 'X' number of days/weeks/etc in set analysis?

Currently, I'm trying to return the last 4 weeks, but I don't believe my results are accurate.

Here's the piece of code I'm using currently..

{<Model2.Week_Res = {"<=$(=( week(date(today(0)))))>=$(=( week(date(today(0) - 4))))"} >}

where Model2.Week_Res is the week #. To ensure this only pulls the latest year, I'll include Model2.Year_Res  = MAX year

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hello Duke,

{<Model2.Year_Res={'$(=Max(Year))'}, Model2.Week_Res={''>=$(=Week(Today(0))-4)<=$(=Week(Today(0)))'}>}

Check out the attachment you will get an idea as how expression works. I used to check my expressions like this.

Capture.PNG

View solution in original post

4 Replies
tamilarasu
Champion
Champion

Hello Duke,

{<Model2.Year_Res={'$(=Max(Year))'}, Model2.Week_Res={''>=$(=Week(Today(0))-4)<=$(=Week(Today(0)))'}>}

Check out the attachment you will get an idea as how expression works. I used to check my expressions like this.

Capture.PNG

lucasdavis500
Creator III
Creator III
Author

Hi Tamil, this doesn't seem to answer the question I've posed. Your QVW is excluding the most recent 4 weeks, I want everything excluded EXCEPT the most recent four weeks. I've tinkered with your formula and still have not been able to get my charts to return the proper values..

neelamsaroha157
Specialist II
Specialist II

Or may be you can use Date field and  WeekStart(Max(Date)-28) & WeekStart(Max(Date)) as your two min & max parameters. You can play with number '28' to fit your requirement.

neelamsaroha157
Specialist II
Specialist II

Also you can try

Right(WeekName(max(Date)),2)-4 & Right(WeekName(max(Date)),2) as your min & max parameter respectively.