Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Eureka99
Contributor II
Contributor II

starting a Fiscal Calendar on a set date

Hi all,

 

I've picked up code for a Fiscal Calendar online.

I've tried to amend this code so that the calendar starts on a specific date.

So i want the calendar to start 01/04/2015.  With the code below it starts in 1898??

Can anyone help and point out what I've done wrong? I am still a noob with Qlikview.

 

 

SET vFiscalYearStartMonth = 4;

Let vDate3 = 01/04/2015;

LET vStartDate = Num(YearStart(vDate3, 0));


LET vEndDate = Num(YearEnd(Today()));

FiscalCalendar:

LOAD

*,

Dual('Q' & Ceil(FiscalMonth/3), Ceil(FiscalMonth/3)) AS FiscalQuarter, // Fiscal Calendar Quarter

Dual(Text(Date(MonthEnd(Date), 'MMM')), FiscalMonth) AS FiscalMonthName; // Fiscal Calendar Month Name

LOAD

*,

Year(Date) AS Year, // Standard Calendar Year

Month(Date) AS Month, // Standard Calendar Month

Date(MonthEnd(Date), 'MMM') AS MonthName,  // Standard Calendar Month Name

Dual('Q' & Ceil(Month(Date)/3), Ceil(Month(Date)/3)) AS Quarter,  // Standard Calendar Quarter

Mod(Month(Date) - $(vFiscalYearStartMonth), 12)+1 AS FiscalMonth,  // Fiscal Calendar Month

YearName(Date, 0, $(vFiscalYearStartMonth)) AS FiscalYear;  // Fiscal Calendar Year

LOAD

Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS Date,

RangeSum(Peek('RowNum'), 1) AS RowNum

AutoGenerate vEndDate - vStartDate + 1;

 

Labels (1)
1 Solution

Accepted Solutions
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Change your variables to :

SET vDate3 = '01/04/2015';

LET vStartDate = Num(YearStart('$(vDate3)', 0));

 

The default variable you posted is evaluating  "1 divide by 4 divide by 2015".

Using "set" enables the variable to be defined as text.

 

Thanks and regards,

Arthur Fong

View solution in original post

1 Reply
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Change your variables to :

SET vDate3 = '01/04/2015';

LET vStartDate = Num(YearStart('$(vDate3)', 0));

 

The default variable you posted is evaluating  "1 divide by 4 divide by 2015".

Using "set" enables the variable to be defined as text.

 

Thanks and regards,

Arthur Fong