Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I've been using the NUM function to extract dates from a timestamp as per below:
num(floor(SettlementTime)) as numDateFLOOR
So far so good, works fine.
However, when applying my master calendar, I cannot make it work properly. No error messages but null values.
Any ideas?´
Thanks in advance,
Olle
MAPPING LOAD
rowno() as Month,
'Q' & Ceil (rowno()/3) as Quarter
AUTOGENERATE (12);
Temp:
Load
min(num(floor(SettlementTime))) as minDate,
max(num(floor(SettlementTime))) as maxDate
Resident ColumnHeader;
Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
DROP Table Temp;
TempCalendar:
LOAD
$(varMinDate) + Iterno()-1 As Num,
Date($(varMinDate) + IterNo() - 1) as TempDate
AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate);
MasterCalendar:
Load
TempDate AS Date,
week(TempDate) As Week,
Year(TempDate) As Year,
Month(TempDate) As Month,
Day(TempDate) As Day,
YeartoDate(TempDate)*-1 as CurYTDFlag,
YeartoDate(TempDate,-1)*-1 as LastYTDFlag,
inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,
date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,
ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,
Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,
WeekDay(TempDate) as WeekDay
Resident TempCalendar
Order By TempDate ASC;
Drop Table TempCalendar;
Check if the variables (varMinDate, varMaxDate) are actually fetching any value.
Hard to say what's wrong without looking at the data. However, you're reinventing a wheel. That's fine if you're trying to learn how this all works, but if you simply want something that works and is easy to reuse then have a look at the Qlikview Components library. See this discussion for more information: Tutorial - Using Common Date Dimensions and Shared Calendars