Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Puffy
Contributor III
Contributor III

Newbie question about script

Dear experts, 

I am following the Qlik Sense Cookbook second edition to learn more about the tool, and in the Script session, I followed the instruction on the book, with a script provided in the book,  see as follow: 

This is the script provided in the cookbookThis is the script provided in the cookbook

and I click load data, below show up: 

and it said date range from 2019 to todayand it said date range from 2019 to today

However, when I check the data in data manager, it shows below: 

The the years show 1899 to 1909The the years show 1899 to 1909

Would be great if someone can tell me there I did wrong? thank you experts!

Labels (1)
1 Solution

Accepted Solutions
uacg0009
Partner - Specialist
Partner - Specialist

Hi Puffy,

Please change to below script, then try:

SET vMinDate = DATE(Floor(MakeDate(2010,1,1)),'DD/MM/YYYY');
SET vMaxDate = DATE(Floor(Today()),'DD/MM/YYYY');
LET vDiff = $(vMaxDate) - $(vMinDate) + 1;

t1:
LOAD DateID,
Year(DateID) as Year;
LOAD RecNo() - 1 + $(vMinDate) as DateID,
	RecNo() as recno
AutoGenerate $(vDiff);

It works in my desktop.

Thanks.

Aiolos Zhao

View solution in original post

4 Replies
dwforest
Specialist II
Specialist II

check what your DateFormat is (variable in first section of script), is it "DD/MM/YYYY" ?
uacg0009
Partner - Specialist
Partner - Specialist

Hi Puffy,

Please change to below script, then try:

SET vMinDate = DATE(Floor(MakeDate(2010,1,1)),'DD/MM/YYYY');
SET vMaxDate = DATE(Floor(Today()),'DD/MM/YYYY');
LET vDiff = $(vMaxDate) - $(vMinDate) + 1;

t1:
LOAD DateID,
Year(DateID) as Year;
LOAD RecNo() - 1 + $(vMinDate) as DateID,
	RecNo() as recno
AutoGenerate $(vDiff);

It works in my desktop.

Thanks.

Aiolos Zhao

Puffy
Contributor III
Contributor III
Author

Thanks, it works now. 

Good day!

Legrosa
Contributor
Contributor

Hi

I had this problem and the answer here solved it for me, thankyou .  If I could trouble you for further clarification.

The issue seemed to have been the using of "Let" instead of "Set" so that the let command set the variable to a value and the set command set it to an expression. My issue is that why did it not work when using the LET when value would have been '2010-01-01'. If the value is hard coded in the LOAD then it worked as it did with using the SET. vMinDate never changes so why hard coded and expression works but LET evaluation does not confuses me.

Thankyou in anticipation.