Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

burak_ersoy
New Contributor III

Variables in Load Editor and CHR(39)

Dear All,

Hope you are doing great and I will appreciate it if you can help me with this problem. I created a variable in a sheet named as vBetweenRolling5 and defined as

{"$(= '>=' & FirstDayMonthRolling5 & '<=' & LastDayMonthRolling5)"}

Everything was working as it suppose to; however, I wanted to transfer all my variables to data load level. Therefore, I created the load script as

LET vBetweenRolling5 = '{"$(= ' & CHR(39) & '>=' & CHR(39) & ' & FirstDayMonthRolling5 & '& CHR(39) & '<=' & CHR(39) & ' & LastDayMonthRolling5)"}';

However, the variable was created in debug as

{""}

Please see the screenshot:

Capture.PNG

Any suggestions?

Thanks a million in advance!

1 Solution

Accepted Solutions
burak_ersoy
New Contributor III

Re: Variables in Load Editor and CHR(39)

cleveranjos‌, got it! However, my confusion was about using & character as the dummy. Because I have other & characters in the script; therefore, your solution was fixing all of it. I changed the code as

LET vBetweenRolling5 = '{"%(= '&CHR(39)&'>='&CHR(39)&' & FirstDayMonthRolling5 & '&CHR(39)&'<='&CHR(39)&' & LastDayMonthRolling5)"}';

LET vBetweenRolling5 = REPLACE(vBetweenRolling5 ,'%','$');

So using % instead of & character fixed the issue. Thank you very much for this answer!

6 Replies
Employee
Employee

Re: Variables in Load Editor and CHR(39)

Try with this, it´s a known issue

LET vBetweenRolling5 = '{"&(= ' & CHR(39) & '>=' & CHR(39) & ' & FirstDayMonthRolling5 & '& CHR(39) & '<=' & CHR(39) & ' & LastDayMonthRolling5)"}'; 

Let vBetweenRolling5  = Replace(vBetweenRolling5 ,'&','$')

burak_ersoy
New Contributor III

Re: Variables in Load Editor and CHR(39)

cleveranjos‌, thank you for your answer. It looks like it works in debugger. I will check and try it in the real app ASAP. However, can you please explain how the replace function fixes this issue?

Employee
Employee

Re: Variables in Load Editor and CHR(39)

The main reason is when Qlik parses the $ into your Let command it will try to evaluate you expression at that specific time.

Using another char ( & for example ) and replacing it later, the parsers does not 'touch' the string

burak_ersoy
New Contributor III

Re: Variables in Load Editor and CHR(39)

cleveranjos‌, got it! However, my confusion was about using & character as the dummy. Because I have other & characters in the script; therefore, your solution was fixing all of it. I changed the code as

LET vBetweenRolling5 = '{"%(= '&CHR(39)&'>='&CHR(39)&' & FirstDayMonthRolling5 & '&CHR(39)&'<='&CHR(39)&' & LastDayMonthRolling5)"}';

LET vBetweenRolling5 = REPLACE(vBetweenRolling5 ,'%','$');

So using % instead of & character fixed the issue. Thank you very much for this answer!

Employee
Employee

Re: Variables in Load Editor and CHR(39)

good to read that

Would you mind markin my answer as "helpful"?

burak_ersoy
New Contributor III

Re: Variables in Load Editor and CHR(39)

My pleasure!