Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Asuod_
Contributor III
Contributor III

Variable Wont Store Dates for Master Calendar

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)';

Labels (5)
1 Solution

Accepted Solutions
Daniel_Pilla
Employee
Employee

Hi @Asuod_ ,

Two things:

  1. You are tracing the wrong variable name for end date. It should be "vLastDate" and not "LastDate".
  2. Your code looks correct otherwise, so your dates are likely not in the format you want them to be in. If they are not being picked up as dates, you need to use "Date#()" and define the date format in the second argument.

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,

View solution in original post

4 Replies
Ahidhar
Creator III
Creator III

Don't think there is  anything wrong with the code just drop the table Dates at the end and see if it works

marcus_sommer

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)';

Asuod_
Contributor III
Contributor III
Author

Asuod__2-1703177773431.png

Variables still not coming through.

Daniel_Pilla
Employee
Employee

Hi @Asuod_ ,

Two things:

  1. You are tracing the wrong variable name for end date. It should be "vLastDate" and not "LastDate".
  2. Your code looks correct otherwise, so your dates are likely not in the format you want them to be in. If they are not being picked up as dates, you need to use "Date#()" and define the date format in the second argument.

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,