Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
MikeJones
Creator
Creator

Show current week

Hi, I wish to have a table that shows the current week data, however should the day be Monday that I look at it, I wish to show all of the previous week's data.  Given that today is Thursday 28th September, my table would show the data under Current Week.  Looking at the report on Monday 25th September, it would show the data as in Previous week.

I have tried using WeekStart, WeekDay and I have got myself into a muddle.

Current Week   Previous Week
Date Sales   Date Sales
Total 270   Total 280
25/09/2023 80   18/09/2023 10
26/09/2023 90   19/09/2023 20
27/09/2023 100   20/09/2023 30
      21/09/2023 40
      22/09/2023 50
      23/09/2023 60
      24/09/2023 70

 

 

Labels (4)
4 Replies
Or
MVP
MVP

Presumably you'd need the date value to be between WeekStart(Today()-7) and WeekEnd(Today()-7). If you'd like that to be offset by an extra day, just subtract an extra one from the value (minus 8 instead of 7).

Gabbar
Specialist
Specialist

Generate the Dates in Load Script, and then add a flag in the Table of those Dates, Join that Table to calendar or let it remain Linked, Use that Flag Field in Set analysis to write.
For Generating Dates in script:-
vToday = Floor(Num(Today()));
vToday_Day = Weekday(vToday);
vMonday = Floor(Num(WeekStart(Today())+1));
Trace $(vMonday);
Trace $(vToday_Day);

If '$(vToday_Day)' = 'Mon' then
A:
Load Date(($(vToday) - 8 + RecNo())) as Date,
WeekDay($(vToday) - 8 + RecNo()) As Day_Name,
'1' as Week_Flag
AutoGenerate 7;
Else
A:
Load Date($(vMonday) - 1 + RecNo()) as Date,
Weekday($(vMonday) - 1 + RecNo()) as Day_Name,
'1' as Week_Flag
AutoGenerate $(vToday) - $(vMonday) + 1;
End If;

After this use Week_Flag = {'1'} in set analysis.
Now with every Reload Week_Flag value will reset itself  and your set analysis would be correct;
OR
YOu can try and use Date = {">=$(Floor(Num(WeekStart(Today())+1)))"}  in set analysis.

MikeJones
Creator
Creator
Author

Gabbar & the MVP, is there any way I can use the dimension in my table to automatically show the dates?

I don't wish to use the load script as other are also using this app and the load script could be a "mess".

Or
MVP
MVP

You should be using the measures, rather than the dimensions, for this. @Gabbar has suggested a basic set at the end of their post, and you can adapt that using my original suggestion to get the values for the current and previous weeks.