Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
BartVA
Creator
Creator

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
Creator
Creator
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
Creator
Creator
Author

OK, yes, very clear, thank you!