Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
okin_pfa
Contributor II
Contributor II

Data from last Week(s)

Hi everyone!

My goal is to show the sum of data for the last eight weeks separately for each week, even though the day changes. 
The working week starts on Mon and ends on Sun.

I want to have a clickable option:
- Last week
- 2 weeks ago
- 3 weeks ago
- 4 weeks ago ...

Labels (3)
1 Reply
Ruhulessin
Partner - Contributor III
Partner - Contributor III

Hi @okin_pfa,

You can create 8 columns containing a measure pointing out to the week you want to show based on the selected date in your app.

Try this:
Column 1 (CW-1): Sum({<Date = {"<=$(=WeekEnd(Max(Date), -1)) >=$(=WeekStart(Max(Date), -1))"}>} Field)
Column 2 (CW-2): Sum({<Date = {"<=$(=WeekEnd(Max(Date), -2)) >=$(=WeekStart(Max(Date), -2))"}>} Field)
.... and so on ...

In your script it needs to be stated that the week starts on Monday, then it will know it ends on Sunday.
SET FirstWeekDay =0; 
More info about this variable can be found here: https://help.qlik.com/en-US/qlikview/May2022/Subsystems/Client/Content/QV_QlikView/Scripting/NumberI...

-Ruben

I have never done it, so I think I can.