Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am new to Qlikview and still practising my skills. I decided to apply Qlikview to Microsofts Northwind database for practise purposes. Amongst other tables I created an Order and OrderDetails Table - each with an added calculated column OrderValue and LineTotal respectively. (Original - I know!). I created a pivot table of with Customer and Year as Dimensions and (initially) Sum(LineTotals) and later Sum(OrderValue). In both cases the pivot table displayed most of the rows exactly as expected but for some customers it created a blank year column and placed values in there. More investigation showed that these were the values from one or more Orders from the last year (1994) even though the Orders clearly had a 1994 orderdate. Any clues as to what is going on here? All the Order Details have corresponding Orders and v.v.
The hard coding generates a lot of unused dates but the following appears to work and do what the original code was supposed to do:
Period:
LOAD Min(OrderDate) as StartDate,
Max(OrderDate) as EndDate
RESIDENT Orders;
LET varMinDate = Num(Peek('StartDate',0,'Period'));
LET varMaxDate = Num(Peek('EndDate',0,'Period'));
LET varToday = num(Today());
//*************************** Temporary Calendar****************
TempCalendar:
LOAD
$(varMinDate) + rowno() - 1 as Num,
date($(varMinDate) + rowno() -1) AS TempDate
AUTOGENERATE
$(varMaxDate)-$(varMinDate)+1;
MasterCalendar:
LOAD TempDate as OrderDate,
week(TempDate) as Week,
Year(TempDate) as Year,
Month(TempDate) as Month,
Day(TempDate) as Day,
WeekDay(TempDate) as WeekDay,
'Q'&ceil(Month(TempDate)/3) AS Quarter,
Date(monthstart(TempDate),'MMM-YYYY') As MonthYear,
Week(TempDate)&'-'&Year(TempDate) AS WeekYear,
inyeartodate(TempDate,$(varToday),0)*-1 AS CurYTDFlag,
inyeartodate(TempDate,$(varToday),-1)*-1 AS LastYTDFlag
RESIDENT TempCalendar
ORDER BY TempDate ASC;
DROP TABLE TempCalendar;