Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
lucasdavis500
Creator III
Creator III

Rename Dimension x-axis values

Is there a way to label what values are shown on the x-axis?

For example:

last_week.png

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?

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

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.

View solution in original post

14 Replies
neelamsaroha157
Specialist II
Specialist II

Are you looking for something like this

Capture.PNG

If yes, then you can use this as your calculated dimension

Capture.PNG

Variables defined are

Capture.PNG

Hope this helps.

johnw
Champion III
Champion III

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.

lucasdavis500
Creator III
Creator III
Author

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

lucasdavis500
Creator III
Creator III
Author

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

lucasdavis500
Creator III
Creator III
Author

Hi John, I've tried this:

IF(Model2.WeekYear_ResWEEK(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:

http://qlikviewcookbook.com/2010/07/the-now-trap/

lucasdavis500
Creator III
Creator III
Author

Solved in script using

IF(Model2.Week_ResWEEK(TODAY(0)) AND Model2.Year_Res = YEAR(TODAY(0)), 'Current Week', 0) AS WeekRes_Flag

lucasdavis500
Creator III
Creator III
Author

Correction: not resolved because qlikview doesn't like

IF(Model2.Week_ResWEEK(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.

johnw
Champion III
Champion III

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

Capture.PNG

MarcoWedel

Hi,

another solution might be:

QlikCommunity_Thread_239585_Pic2.JPG

QlikCommunity_Thread_239585_Pic1.JPG

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