Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there a way to label what values are shown on the x-axis?
For example:
I would like 45-2016 to be renamed 'Current Week', 44-2016, 'Last Week', 43-2016, 'Two Weeks Ago', and so on and so forth..
Is this possible?
I'd probably simplify a little and just do this:
date(weekstart(Date),'MMM D YYYY') as Week_Start
But for exactly what you show, I suppose:
dual(date(weekstart(Date),'MMM D') & ' - ' & date(weekend(Date),'MMM D YYYY'),weekstart(Date)) as Week_Year
It would be a little funny, with weeks like Dec 27 - Jan 2 2016, but I suppose that's still clear enough without putting 2015 in there as well.
Are you looking for something like this
If yes, then you can use this as your calculated dimension
Variables defined are
Hope this helps.
If current week is based on today and not on selections, you could load these labels in script as a [Week Label] field, say. Use that as your dimension instead of your Week field.
If you're using Week year as your dimension, then MAX(RIGHT([WEEK_YEAR], 2)) is going to return '16' for 2016.... not the two digits for the actual week number. I think it may need to be LEFT
My WEEK(DATE) returns all of my weeks to date, but has '53' included. This is causing an error with this formula. Any idea why '53' shows up in my data, even though my data begins 1/1/2016
Hi John, I've tried this:
IF(Model2.WeekYear_Res = WEEK(WEEKSTART(today(1))) & '-' & WEEKYEAR(today(1)), 'Current Week', ) AS WeekRes_Flag
Which doesn't seem to be working properly. Is this what you were suggesting to do in the script? This is assigning 'Current Week' to every week.
using today(1) because apparently today(0) in script is the time of two script executions, not the latest script execution, according to:
Solved in script using
IF(Model2.Week_Res = WEEK(TODAY(0)) AND Model2.Year_Res = YEAR(TODAY(0)), 'Current Week', 0) AS WeekRes_Flag
Correction: not resolved because qlikview doesn't like
IF(Model2.Week_Res = WEEK(TODAY(0))-1 AND Model2.Year_Res = YEAR(TODAY(0)), 'Current Week', 0) AS WeekRes_Flag
OR
IF(Model2.Week_Res = (WEEK(TODAY(0))-1) AND Model2.Year_Res = YEAR(TODAY(0)), 'Current Week', 0) AS WeekRes_Flag
Does anyone know how to resolve Week # in the script?
EDIT: This doesn't work using TODAY(1), either.
I don't think I'd use flags. After some further thinking, I think I'd completely redefine my WeekYear field to be something like this. These should display as desired, but numerically are the first day of each week, so will also sort correctly if sorted numerically
,dual(if((weekstart(today())-weekstart(Date))/7<=5
,pick(1+ (weekstart(today())-weekstart(Date))/7
,'Current Week'
,'Last Week'
,'Two Weeks Ago'
,'Three Weeks Ago'
,'Four Weeks Ago'
,'Five Weeks Ago') // add as many as you want
,week(Date)&'-'&weekyear(Date)) // default if not named
,weekstart(Date)) as WeekYear
Hi,
another solution might be:
tabTempWeekNames:
LOAD Dual(WeekAge, WeekStart(Today(),1-RecNo())) as WeekAge
Inline [
WeekAge
Current Week
Last Week
Two Weeks Ago
Three Weeks Ago
Four Weeks Ago
Five Weeks Ago
];
tabShortCalendar:
LOAD *,
WeekDay(Date) as WeekDay,
WeekStart(Date) as WeekStart,
WeekStart(Date) as WeekAge;
LOAD Date(Today()-RecNo()+1) as Date
AutoGenerate 35;
DROP Table tabTempWeekNames;
hope this helps
regards
Marco