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: 
BartVA
Contributor III
Contributor III

Load script variable remains NULL

I must be doing something really stupid but I don't know what...

I need to put the minimum value of a field ("Date") in a variable in the load script.

First I load a table with only the minimum Date:

tTempMinDate:
LOAD
    Min(Num("Date")) as TempMinDate
FROM [lib://MyPath/tProductAvailability.csv]
(txt, utf8, embedded labels, delimiter is ',', msq)
group by "Date";

The result looks fine:

BartVA_1-1633793273010.png

But the next bit of code gives as a result NULL:

LET varMinDate = Num(Min(TempMinDate));

BartVA_2-1633793437786.png

What is wrong with the LET statement?

Many thanks in advance!

 

 

1 Solution

Accepted Solutions
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hello,

Try below.

Let Vmindate = peek('TempMinDate',0,'tTempMinDate');

 

Thanks,
Ashutosh

View solution in original post

4 Replies
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hello,

Try below.

Let Vmindate = peek('TempMinDate',0,'tTempMinDate');

 

Thanks,
Ashutosh

BartVA
Contributor III
Contributor III
Author

Yes, great, that works! Thank you!

Could you explain why

LET varMinDate = Num(Min(TempMinDate));

doesn't work?

AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hello,

LET varMinDate = Num(Min(TempMinDate)); 

will not work as there is no table exist for TempMinDate in the variable statement.

We define Field Name, Row Position and Table name in the Peek function so that LET condition gets to know from where to pick the min value of date.

 

The other ways is to enclose the Let statement in single quotes and evaluate it in the frontend using $(Variable).

E.g 

LET varMinDate = 'Num(Min(TempMinDate))';

Use $(varMinDate) in the KPI to get the min value of date.

 

I hope that solves your query.

 

Thanks,

Ashutosh

BartVA
Contributor III
Contributor III
Author

OK, yes, very clear, thank you!