Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear Qlik Gurus,
I wanted to use following statement in script
set vMaxDate='[Reference Date]={"$(=max([Reference Date]))"}';
to use variable in set analysis.
The weird thing is that the resulting value of the variable after reloading is
[Reference Date]={""}
I completely don't understand why. I always thought that set stores values literally, but it looks like Qlik is trying to execute the function max.
Thanks in advance
BR
M.
Because the $() expansion executes before the Set statement. You need to defer the expansion, like
Let vMaxDate = '[Reference Date]={"$' & '(=max([Reference Date]))"}';
How your set expression looks like in UI?
Because the $() expansion executes before the Set statement. You need to defer the expansion, like
Let vMaxDate = '[Reference Date]={"$' & '(=max([Reference Date]))"}';
You can try calling the max reference date first, then peek at the value.
TempMaxDate:
LOAD
max([Reference Date]) as maxRefDate
Resident [yourtable];
Let vMaxRefDate=peek('maxRefDate');
Drop Table TempMaxDate;
(You may need to throw some date formatting in there - depending on your data.)
Thanks Jonathan. That was it. I've used replace function
set vMaxDate = '[Reference Date]={"@(=max([Reference Date]))"}';
let vMaxDate =replace(vMaxDate,'@',$')
All the best.