Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
But the next bit of code gives as a result NULL:
LET varMinDate = Num(Min(TempMinDate));
What is wrong with the LET statement?
Many thanks in advance!
Hello,
Try below.
Let Vmindate = peek('TempMinDate',0,'tTempMinDate');
Thanks,
Ashutosh
Hello,
Try below.
Let Vmindate = peek('TempMinDate',0,'tTempMinDate');
Thanks,
Ashutosh
Yes, great, that works! Thank you!
Could you explain why
LET varMinDate = Num(Min(TempMinDate));
doesn't work?
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
OK, yes, very clear, thank you!