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

Calendrier : semaine décalée

Bonjour à tous, 

Je rencontre un petit soucis avec les calendriers sur QS, 2020 étant une année à 53 semaines , le 1er , le 2 et le 3 Janvier 2021 se retrouvent en S53, et donc la S01 de 2021 débute au 4 Janvier, est ce qui'l y a une possibilité de dire que la S1 débute au 1 er Janvier et donc bypasser la S53 ?

Par avance merci et bonne journée.

 

Barba

7 Replies
Prashant_N
Contributor III
Contributor III

Hi,

Try to implment Master Calendar with below script.

[Calendar]:
SET vFiscalYearStartMonth = 4;

LET vStartDate = NUM(Makedate(2018,01,01));
LET vEndDate = NUM(FLOOR(Makedate(2021,07,31)));

Calendar:
LOAD * ,
DUAL('Q' & CEIL(FiscalMonth/3), Ceil(FiscalMonth/3)) as FiscalQuarter, // Fiscal Calendar Quarter
DUAL(TEXT(DATE(MONTHEND(CalDate1), 'MMM')), FiscalMonth) as FiscalMonthName; // Fiscal Calendar Month Name

LOAD * ,
DATE(NUM(CalDate1)) as "DATE",
DATE(CalDate1) as DATE1,
YEAR(CalDate1) as CalYear, // Standard Calendar Year
MONTH(CalDate1) as CalMonth,// Standard Calendar Month
DATE(CalDate1, 'YYYY-MM') as CalPeriod,
WEEK(CalDate1) as WeekName,
DATE(MonthStart(CalDate1),'MMM-YY') as CalYear_Month,
DATE(MonthStart(CalDate1),'MMM-YY') as FYear_Month,
DATE(MONTHEND(CalDate1), 'MMM') as CalMonthName, // Standard Calendar Month Name
DUAL('Q' & CEIL(MONTH(CalDate1)/3), CEIL(MONTH(CalDate1)/3)) as CalQuarter, // Standard Calendar Quarter
MOD(Month(CalDate1) - $(vFiscalYearStartMonth), 12)+1 as FiscalMonth,// Fiscal Calendar Month
YEARNAME(DATE(CalDate1), 0, $(vFiscalYearStartMonth)) as FiscalYear;

LOAD
DATE($(vStartDate) + ITERNO() - 1) as CalDate1
AUTOGENERATE (1)
WHILE $(vStartDate) + ITERNO() - 1 <= $(vEndDate);

DROP FIELD CalDate1;

The WeekName field will be your week.

Regards,

Prashant

barbawawa
Contributor III
Contributor III
Author

Hi Prashant,

I have just to cut and paste the script ?

Prashant_N
Contributor III
Contributor III

Hi,

Yes, You can do that for testing. but with the real data you have to pass the Min and Max date from you datamodel.

Regards,

Prashant

barbawawa
Contributor III
Contributor III
Author

sorry for my ignorance, but where should I fill in my dates ? i don' understand

 

Prashant_N
Contributor III
Contributor III

In this area of provided script.

LET vStartDate = NUM(Makedate(2018,01,01));
LET vEndDate = NUM(FLOOR(Makedate(2021,07,31)));

 

barbawawa
Contributor III
Contributor III
Author

ok i filled in as is :

LET vStartDate = NUM(Makedate(2021,01,01));
LET vEndDate = NUM(FLOOR(Makedate(2021,12,31)));

But it doesn't work 😞 (see Screenshot)

barbawawa
Contributor III
Contributor III
Author

Hello, by reading the documentation, I found the solution to my problem, it was necessary to modify the settings of the native calendar in QS (see PJ)