Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
my code is
pls help
tab1:
LOAD * Inline [
id,productname,price,geog,date
1,lenova,25000,uk,1-1-2010
2,dell,18000,us,1-2-2011
3,acer,25000,ind,12-11-2012
4,asus,28000,uk,13-10-2013
5,hp,21000,jer,15-09-2014
];
sort:
LOAD * Resident tab1 Order by date;
LET vmax= Num(Peek('date',-1,'sort'));
LET vmin = Num(Peek('date',0,'sort'));
temp:
Load
date($(vmin) + rowno() -1) As tempdate
Autogenerate
$(vmax)-$(vmin)+1;
mastercalender:
LOAD tempdate,
tempdate as datefield,
Year(tempdate) as year,
Month(tempdate) as month,
'Q'&Ceil(Month(tempdate)/3) as quarter,
Week(tempdate) as week
Resident temp ;
Most likely your date values like '1-1-2010' are not recognized as dates. Try using the date# function in the first load to create real date values:
tab1:
LOAD id,productname,price,geog,date(date#(date,'D-M-YYYY'),''D-M-YYYY) as date Inline [
id,productname,price,geog,date
1,lenova,25000,uk,1-1-2010
2,dell,18000,us,1-2-2011
3,acer,25000,ind,12-11-2012
4,asus,28000,uk,13-10-2013
5,hp,21000,jer,15-09-2014
];
Following on from Gysbert, try something like this :
tab1:
LOAD
id,
productname,
price,
geog,
date(date#(date,'D-M-YYY')) as date
;
load * Inline [
id,productname,price,geog,date
1,lenova,25000,uk,1-1-2010
2,dell,18000,us,1-2-2011
3,acer,25000,ind,12-11-2012
4,asus,28000,uk,13-10-2013
5,hp,21000,jer,15-09-2014
];
temp1:
LOAD date as tempdate Resident tab1 Order by date;
LET vmax= num(Peek('tempdate',-1));
LET vmin = num(Peek('tempdate',0));
drop table temp1 ;
temp2:
Load
rowno() ,
date($(vmin) + rowno() -1) As tempdate
Autogenerate
$(vmax)-$(vmin)+1;
mastercalender:
LOAD tempdate,
tempdate as datefield,
Year(tempdate) as year,
Month(tempdate) as month,
'Q'&Ceil(Month(tempdate)/3) as quarter,
Week(tempdate) as week
Resident temp2 ;
drop table temp2;