Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
QVUser1
Partner - Contributor III
Partner - Contributor III

LOAD 4 weeks as a Dimension

Hi all,

I need last 4 weeks as Dimension Where I am having Week number in my Table .

QVUser1_0-1627440208950.png

 

2 Solutions

Accepted Solutions
anthonyj
Creator III
Creator III

Hi,

Assuming that you are in week 11 of the current year you could add the below to your script:

DataSet:

load 

  [Week Number],

if(num([Week Number]) >= week(today())-4, 'Last 4 Weeks')  as [Week FLAG]

from YourData;

This should add the flag dynamically as the weeks gradually progress through the year and reload data.

 

View solution in original post

anthonyj
Creator III
Creator III

Hi,

If you need to exclude records from the current week then you can add a 'where' statement to the bottom of your script. To change which weeks get flagged we just need to alter the condition in the 'if' statement.

load 

  [Week Number],

if(num([Week Number]) >= week(today())-6, 'Last 5 Weeks')  as [5 Week FLAG]

from YourData

where num([Week Number]) < week(today());

Since you are now dropping week 11 from your data and you want to flag 5 weeks you need to shift it back 6 weeks to get 6,7,8,9,10.  

Let me know if you have any other questions.

Thanks

View solution in original post

4 Replies
Chanty4u
MVP
MVP

Hi You can try in script 

LOAD weekflag

FROM yourLocation

Where Len(Trim(Weekflag)) <> 0;

or

check option supressnull values in dimension 

 

 

anthonyj
Creator III
Creator III

Hi,

Assuming that you are in week 11 of the current year you could add the below to your script:

DataSet:

load 

  [Week Number],

if(num([Week Number]) >= week(today())-4, 'Last 4 Weeks')  as [Week FLAG]

from YourData;

This should add the flag dynamically as the weeks gradually progress through the year and reload data.

 

QVUser1
Partner - Contributor III
Partner - Contributor III
Author

Hi,

Thanks For the Reply ...

I need also Like this  , My current Week is 11 th Week , I Need Exclude it and display last 5 Weeks as 10,9,8,7,6

anthonyj
Creator III
Creator III

Hi,

If you need to exclude records from the current week then you can add a 'where' statement to the bottom of your script. To change which weeks get flagged we just need to alter the condition in the 'if' statement.

load 

  [Week Number],

if(num([Week Number]) >= week(today())-6, 'Last 5 Weeks')  as [5 Week FLAG]

from YourData

where num([Week Number]) < week(today());

Since you are now dropping week 11 from your data and you want to flag 5 weeks you need to shift it back 6 weeks to get 6,7,8,9,10.  

Let me know if you have any other questions.

Thanks