Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
stephenedberkg
Creator II
Creator II

Redefining Week

i have the date field its start from 12-28-2014 want to set this date as 1st week so on...

while using master calendar i can't achieve this in master calendar.

how can i achieve this below output while using the master calendar.

PFA of QVW.

    

2015                                      2016
WEEKNODATE                              WEEKNODATE
1 12/28/2014112/27/2015
21/4/201521/3/2016
31/11/201531/10/2016
41/18/201541/17/2016
51/25/201551/24/2016
62/1/201561/31/2016
72/8/201572/7/2016
82/15/201582/14/2016
92/22/201592/21/2016
103/1/2015102/28/2016
113/8/2015113/6/2016
123/15/2015123/13/2016
133/22/2015133/20/2016
143/29/2015143/27/2016
154/5/2015154/3/2016
164/12/2015164/10/2016
174/19/2015174/17/2016
184/26/2015184/24/2016
195/3/2015195/1/2016
205/10/2015205/8/2016
215/17/2015215/15/2016
225/24/2015225/22/2016
235/31/2015235/29/2016
246/7/2015246/5/2016
256/14/2015256/12/2016
266/21/2015266/19/2016
276/28/2015276/26/2016
287/5/2015287/3/2016
297/12/2015297/10/2016
307/19/2015307/17/2016
317/26/2015317/24/2016
328/2/2015327/31/2016
338/9/2015338/7/2016
348/16/2015348/14/2016
358/23/2015358/21/2016
368/30/2015368/28/2016
379/6/2015379/4/2016
389/13/2015389/11/2016
399/20/2015399/18/2016
409/27/2015409/25/2016
4110/4/20154110/2/2016
4210/11/20154210/9/2016
4310/18/20154310/16/2016
4410/25/20154410/23/2016
4511/1/20154510/30/2016
4611/8/20154611/6/2016
4711/15/20154711/13/2016
4811/22/20154811/20/2016
4911/29/20154911/27/2016
5012/6/20155012/4/2016
5112/13/20155112/11/2016
5212/20/20155212/18/2016
5312/25/2016
8 Replies
Not applicable

Try this pls.

Let vDate=Date(Date#('12/28/2014','MM/DD/YYYY'),'DD/MM/YYYY');
Calendar:
load Date('$(vDate)'+(RowNo()-1)*7) as Date,
if(mod(RowNo(),53)=0,1,
if(Year(Date('$(vDate)'+(RowNo()-1)*7))=2016,
mod(RowNo(),53)+1,
mod(RowNo(),53)
)
)
as WeekNo
autogenerate 105;

migueldelval
Specialist
Specialist

Hi Stephen,

Maybe you can find diferent information in:

How to use - Master-Calendar and Date-Values

Custom Calendar Generator

Regards

Miguel del Valle

stephenedberkg
Creator II
Creator II
Author

where can i put this script inside the master calendar ?

Not applicable

in master calendar only

stephenedberkg
Creator II
Creator II
Author

yeah i cant get , each week have several week stat date

qus

Not applicable

Hi Stephen,

You can try this script as well:

//---------------------------------------------------------------------------


LET vMinDate = 42001;   // Start Date

LET vMaxDate = 42729;  // End Date

//*****Temp Calendar*****

TempCal:

LOAD

  DATE($(vMinDate) + ROWNO() -1) AS TempDate

AUTOGENERATE

  $(vMaxDate) - $(vMinDate) + 1;

Calendar:

Load *, AutoNumber(WeekEnd,YearNo) as WeekNo;

Load *, Year(WeekEnd) as YearNo;

Load

*,

Date(WeekEnd(TempDate+1)-1) as WeekEnd

resident TempCal;

Drop Table TempCal;

//---------------------------------------------------------------------------

Please let me know if it helps!

Regards,

Sakir

stephenedberkg
Creator II
Creator II
Author

hi

sakirali‌‌

its working fine when we give the min and max date .

actually my start date is 7-26--15  (32nd week)

i want to show this week  in selection field of dashboard

if i hardcore the min and max date it take 7-25-15 as 1 st week. but i want this date start as  32nd week of 2015.

Not applicable

Hi,

I think even if you are selecting any random date as your start date, you must keep a certain date as a standard from where the calculation should start.

For example, you can simply write:

LET vStartDate= 42211; //  7/26/2015

LET vMinDate = WeekStart(YearStart(Date(vMinDate)))-1;

and then proceed with the above script.

Hope it helps!

Regards,

Sakir