Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anil_Babu_Samineni

Redefining the Week Numbers

Hello,

Why my week is not working Properly, Up to Year end should show week 52/53 and then should be start the week from 1 Again.

Redefining the Week Numbers

Can you please help me.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
17 Replies
Anil_Babu_Samineni
Author

Hello Sir,

I didn't get any difference? Can you please have a look which you shared before and Recent, Please?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

canyou provide only script with your mastercalender?

I will then check

Anil_Babu_Samineni
Author

I already attached with qvw. Anyway, Please find the Script

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

I tried with your script. for 12/29/2014 I get a 53 instead of 1

LET varMinDate = 40909;
LET varMaxDate = 42735;
//LET varMinDate = Num(Peek('MinDate', 0, 'TEMP'));
//LET varMaxDate = Num(Peek('MaxDate' , 0, 'TEMP'));

LET vToday = Num(today());


//drop Table TEMP;

TempCalendar:
LOAD
$(varMinDate)+IterNo()-1 AS Num,
Date($(varMinDate)+IterNo()-1) AS TempDate
AUTOGENERATE 1 WHILE $(varMinDate)+IterNo()-1<= $(varMaxDate);

MasterCalendar:
NoConcatenate LOAD TempDate AS "MainDate",
num(TempDate) AS SummaryDate,
if (week(TempDate)=1 and month(TempDate)='Dec', 53, week(TempDate)) as Week,
// week(TempDate) AS Week,
year(TempDate) AS Year,
month(TempDate) AS Month,
date(TempDate,'MM') as MonthNum,
day(TempDate) AS Day,
day(TempDate)-1 AS PreviousDay,
weekday(TempDate) AS WeekDay,
'Q' &
Ceil(month(TempDate)/3) as Quarter,
date(monthstart(TempDate), 'MMM-YYYY') AS MonthYear,
week(TempDate)&'-'&Year(TempDate) AS WeekYear,
Year2Date(TempDate, 0, 1, $(vToday))*-1 AS CurYTDFlag,
Year2Date(TempDate,-1, 1, $(vToday))*-1 AS LastYTDFlag,
1
as temp
RESIDENT TempCalendar;

Anil_Babu_Samineni
Author

Yes, Correct. I am looking this

But, Here i want to start week from Monday. See for 1st week till sat is there, But, i want to move 2nd Week Sunday to 1st week and then 2nd Week Should start from Monday Onwords.

I Apologize my English

Capture.PNG

Updated: Expecting - Every week starting from Monday

WeekMonTueWedThuFriSatSun
W2627282930010203
W2704050607080910
W2811121314151617
W2918192021222324
W3025262728293031
Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

normal week start on sunday. if you Need that sunday belongs to previous week you Need to adjust the week

if (weekday(TempDate)='Su', week(TempDate)-1, week(TempDate)) as Week

Anil_Babu_Samineni
Author

Yes, as per our adjust it will go.

As Reference, Please find image

Capture.PNG

Note: Here, i want to show 27, 28, 29, 30, 31 for 53 weeks Because Upto December 2015 the weeks are finished. So, here after that I want to show 1, 2, 3 dates for 1st week in 2016 and 4-10 should be 2nd week, Like that...

Thanks you so much for your Response

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni
Author

Rudolf, I got it. Thanks for your Help

I's working with this code

Let vCal_FD = 0; // First Day of the week {0=Mon, 1=Tue, ... , 6=Sun}

Let vCal_BW = 0; // Broken Weeks allowed {0=No, 1=Yes}

Let vCal_RD = 1; // Reference day = This day in Jan defines week one {1..7}

Load

  *,

  if(TempDate < WeekRefDate and WeekNumber=0 and year(TempDate)<WeekYear,53,WeekNumber+1) as Actual_WeekNumber;

Load *,

          Div( TempDate - WeekStart( WeekYearRefDate, 1, $(vCal_FD) ) + 7, 7 ) as WeekNumber,

          Year( WeekYearRefDate ) as WeekYear;

Load *,

          Date( YearStart( If( $(vCal_BW), TempDate, WeekRefDate )) + $(vCal_RD) - 1) as WeekYearRefDate ;

Load *,

          Date( WeekStart( TempDate , 1, $(vCal_FD) ) - $(vCal_RD) ) as WeekRefDate ;

Capture.PNG

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful