Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

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

4 Replies

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

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.

Community Browser