Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Putting Dollar Expansion in Variable


I am setting a variable in the script for use later in Set Analysis, but have had issues with the Dollar Expansion;

As in, this don't work :

let vSetMTYesterday='[Day]={"<=$(=day(today()))"} ';

But replacing the $ with ' & chr(36) & ' then it does work :

let vSetMTYesterday='[Day]={"<=' & chr(36) & '(=day(today()))"} ';

Is this what one would expect ?

Is there a better way of doing this ?

Best Regards,     Bill

4 Replies
Not applicable

Re: Putting Dollar Expansion in Variable


I have the same problem with one of my applications. Try this :

SET vSetMTYesterday = '[Day]={"<=%(=day(today()))"} ';

LET vSetMTYesterday = Replace($(vSetMTYesterday), '%', '$');

It works for me.

Re: Putting Dollar Expansion in Variable


Many thanks for your suggestion which is a different swerve on mine, as in you avoid the $ by using a % and later replacing the % with a $, whereas I use chr(36) that translates to the $ sign.

I'd be interested to hear if we just have live with a frig for this or whether there is a neat, tidy & elegant solution.

Best Regards,     Bill

Re: Putting Dollar Expansion in Variable

This should work too: LET vSetMTYesterday= '[Day]={"<=$' & '(=day(today()))"}';

Sometimes the above is the easiest way to handle this, sometimes a SET and LET + replace is more convenient. It depends for example on how many $ characters you need to 'escape'. But it is something you have to live with. Dollar-expansion is very nice to have, even if it does mean that sometimes you need to do a bit extra to prevent a premature expansion.

talk is cheap, supply exceeds demand
Honored Contributor II

Re: Putting Dollar Expansion in Variable

Can you not just say

LET vMTDYesterday = TODAY()-1;

Community Browser