Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am trying to create a master calendar for two date fields but for some reason when im creating a min and max variable it is not storing or it is storing as a NULL. When I view the Dates tables the max and min values are stored, I assume its something with the Peek function storing the variable but not sure how to fix the issue. Any help is appreciated, thank you.
Dates:
Load
MIN(Date(startdate,'MM/DD/YYYY')) as startdate,
MAX(Date(enddate,'MM/DD/YYYY')) as enddate
resident MockMPData;
LET vFirstDate = NUM(PEEK('startdate',0,'Dates'));
LET vLastDate = NUM(PEEK('enddate',0,'Dates'));
Trace Min is '$(vFirstDate)' and Max is '$(LastDate)';
Hi @Asuod_ ,
Two things:
Here is an example that works, formatting the dates so they are properly registered as a date:
Dates:
LOAD
Min(Date#(startdate,'YYYY/MM/DD')) as startdate,
Max(Date#(enddate,'YYYY/MM/DD')) as enddate
INLINE [
startdate ,enddate
2023/1/10 ,2023/12/1
2022/5/23 ,2022/10/22
];
LET vFirstDate = Peek('startdate',0,'Dates');
LET vLastDate = Peek('enddate',0,'Dates');
TRACE Min is '$(vFirstDate)' and Max is '$(vLastDate)';
If the dates aren't converted properly, then you'll see nulls like you are seeing.
Cheers,
Don't think there is anything wrong with the code just drop the table Dates at the end and see if it works
What happens now?
Dates:
Load
MIN(floor(startdate)) as startdateX,
MAX(floor(enddate)) as enddateX
resident MockMPData;
LET vFirstDate = PEEK('startdateX',0,'Dates');
LET vLastDate = PEEK('enddateX',0,'Dates');
Trace Min is '$(vFirstDate)' and Max is '$(vLastDate)';
Variables still not coming through.
Hi @Asuod_ ,
Two things:
Here is an example that works, formatting the dates so they are properly registered as a date:
Dates:
LOAD
Min(Date#(startdate,'YYYY/MM/DD')) as startdate,
Max(Date#(enddate,'YYYY/MM/DD')) as enddate
INLINE [
startdate ,enddate
2023/1/10 ,2023/12/1
2022/5/23 ,2022/10/22
];
LET vFirstDate = Peek('startdate',0,'Dates');
LET vLastDate = Peek('enddate',0,'Dates');
TRACE Min is '$(vFirstDate)' and Max is '$(vLastDate)';
If the dates aren't converted properly, then you'll see nulls like you are seeing.
Cheers,