Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
gmenoutis
Partner - Creator II
Partner - Creator II

Function works through var but not through script

I have the following formula for a dollar-sign expansion with one parameter:

pick(2+sign($(=only({1<[_MasterItemName]={'$1'}>} [_MasterItemExpression1]))),'#FF0000','#888888','#008800')

If I enter this value exactly as is in the variable window of the edit-mode (I use a variable named color), it works correctly: calling $(color(MasterItemName)) returns me what I want.

But, I cannot seem to make this work if I do the variable assignment on-script. I've tried bot set and let, and both as seen above, and escaped the single quotes with two single quotes.

Any ideas?

1 Solution

Accepted Solutions
rubenmarin

Hi, loading expression from an excel file helps to avoid to use escape character for quotes and $, also helps to centralize maintenance.

https://community.qlik.com/t5/QlikView-App-Dev/Set-Analysis-in-Expression-Chart/m-p/187444#89749

In script maybe doesn't works because you also need to scape the $ character, in example you can use:

set varStart = pick(2+sign(&(=only({1<[_MasterItemName]={|&1|}>} [_MasterItemExpression1]))),|#FF0000|,|#888888|,|#008800|)

let varEnd = replace(replace('$(varStart),'&','$'),'|',Chr(39));

View solution in original post

2 Replies
rubenmarin

Hi, loading expression from an excel file helps to avoid to use escape character for quotes and $, also helps to centralize maintenance.

https://community.qlik.com/t5/QlikView-App-Dev/Set-Analysis-in-Expression-Chart/m-p/187444#89749

In script maybe doesn't works because you also need to scape the $ character, in example you can use:

set varStart = pick(2+sign(&(=only({1<[_MasterItemName]={|&1|}>} [_MasterItemExpression1]))),|#FF0000|,|#888888|,|#008800|)

let varEnd = replace(replace('$(varStart),'&','$'),'|',Chr(39));

gmenoutis
Partner - Creator II
Partner - Creator II
Author

Excellent, thanks! For future reference, you are missing a terminating semicolon on the end of the first command, and also a single quote  after the (varStart) of the second