Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Not applicable

Setting a variable in script...

Hi All,

I want to set a varible from code that results in a YTD-like value (in the attached example). I am able to create an expression in a table to get the result. I can also set the variable in the variablescreen and use that to display the desired value, but because of reasons of reusability and the number of variables I need, I want to set the variable in code. This results in an error.

I have tried a lot, but possibly not everything. Maybe some of you guys might be able to come up with a suitable solution.

Kind regards, vBeijnen

Tags (2)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Setting a variable in script...

It is a difficult matter ... cause are special characters. In most cases it is enough to replace single quotes with double quotes, but here it seems it is the $ sign - see here http://community.qlik.com/message/337484#337484 and also the attachment.

set vFromScript = 'Count({1<Date={"<=#(=max(Date))"}>} Label)';
let vFromScript = replace('$(vFromScript)', '#', chr(36));

- Marcus

View solution in original post

4 Replies
MVP & Luminary
MVP & Luminary

Re: Setting a variable in script...

It is a difficult matter ... cause are special characters. In most cases it is enough to replace single quotes with double quotes, but here it seems it is the $ sign - see here http://community.qlik.com/message/337484#337484 and also the attachment.

set vFromScript = 'Count({1<Date={"<=#(=max(Date))"}>} Label)';
let vFromScript = replace('$(vFromScript)', '#', chr(36));

- Marcus

View solution in original post

Not applicable

Re: Setting a variable in script...

Hi vBeijnein

it is beacause of the $ sign in the string

you have to split up your string like

SET v = first_part_string & chr(36) & second_part_string  : chr(36) for $ sign

Idem ifyou use simple/double cotes

best regards

chris

Not applicable

Re: Setting a variable in script...

Thank you kindly, Marcus!

Not applicable

Re: Setting a variable in script...

Thanks, Christianj, Marcus beat you to it... this time.