Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I'm trying to create a calendar dimension containing all the possible dates between a min(date) and max(date), I don't knwo if the way I'm doing it si correct / possible? It doesn't fail when refreshing but TIMEDIM table is not created.
Dates:
LOAD date(max(ORDERS.SO_DTL_CRT_DT)) as MaxDate,
date(min(ORDERS.SO_DTL_CRT_DT)) as MinDate
Resident ORDERS;
LET vMaxDate = Peek('MaxDate',0,'Dates');
LET vMinDate = Peek('MinDate',0,'Dates');
DROP Table Dates;
TIMEDIM:
LOAD $(vMinDate) + (IterNo()-1) as Date
while $(vMinDate)+ (IterNo()-1)<= $(vMaxDate);
The basic issue that I can see is formatting your min and max values as dates - the date values don't work as well in the following logic. Try the same, keeping the numbers as numeric values.
The second problem is that the last load doesn't have any source of the data (from/resident/autogenerate) and therefore it's considered as a Preceding load. I added Autogenerate to your logic.
cheers,
Oleg Troyansky
www.masterssummit.com - take your QlikView skills to the next level!
Dates:
LOAD
max(ORDERS.SO_DTL_CRT_DT) as MaxDate,
min(ORDERS.SO_DTL_CRT_DT) as MinDate
Resident ORDERS;
LET vMaxDate = Peek('MaxDate',0,'Dates');
LET vMinDate = Peek('MinDate',0,'Dates');
DROP Table Dates;
TIMEDIM:
LOAD
Date($(vMinDate) + (IterNo()-1)) as Date
Autogenerate 1
while $(vMinDate)+ (IterNo()-1)<= $(vMaxDate)
;
i suggest stepping through your code with the debugger to figure out if there is any loop happening. One guess is just that the formats are not compatible because one side is using an addition and the other is not .
Ex:
TIMEDIM:
LOAD $(vMinDate) + (IterNo()-1) as Date
while date($(vMinDate)+ (IterNo()-1))<= date($(vMaxDate));
Here is also an alternative code:
TIMEDIM:
LOAD date( $(vMinDate) + (IterNo()-1)) as Date
autogenerate $(vMaxDate)-$(vMinDate)+1 ;
Check this thread out. It has a video as well.
The basic issue that I can see is formatting your min and max values as dates - the date values don't work as well in the following logic. Try the same, keeping the numbers as numeric values.
The second problem is that the last load doesn't have any source of the data (from/resident/autogenerate) and therefore it's considered as a Preceding load. I added Autogenerate to your logic.
cheers,
Oleg Troyansky
www.masterssummit.com - take your QlikView skills to the next level!
Dates:
LOAD
max(ORDERS.SO_DTL_CRT_DT) as MaxDate,
min(ORDERS.SO_DTL_CRT_DT) as MinDate
Resident ORDERS;
LET vMaxDate = Peek('MaxDate',0,'Dates');
LET vMinDate = Peek('MinDate',0,'Dates');
DROP Table Dates;
TIMEDIM:
LOAD
Date($(vMinDate) + (IterNo()-1)) as Date
Autogenerate 1
while $(vMinDate)+ (IterNo()-1)<= $(vMaxDate)
;
Tried both, none worked
When debugging the values for vMinDate and vMaxDate are correct, but nothing happen, when clicking on "Step" it simply ends running
Worked like a charm, thanks Oleg.
Your right .. forgot to replace iterno() with rowno() (for the 2nd example)
TIMEDIM:
LOAD date( $(vMinDate) + (rowno()-1)) as Date
autogenerate $(vMaxDate)-$(vMinDate)+1 ;