Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

String variable in script

Hello,

I am trying to define a string variable and use it in a script. It works fine if I create the variable in the Variable Viewer:

Variable name = Status

Value = 'OK'

LOAD

    INFO,

    if(INFO=$(Status), $(Status), 'KO') AS INFO2

FROM file.xlsx [...];

But when I try to declare the variable in the script it fails:

SET Status='OK'; //I also tried SET Status="OK";

LOAD

    INFO,

    if(INFO=$(Status), $(Status), 'KO') AS INFO2

FROM file.xlsx [...];

Error:

Field not found <OK>

if(Status=OK,OK,'') AS INFO2

Quotes around 'OK' are removed so string OK is seen as a field name instead of a string value. If you look at the variable in the Variable Viewer:

Variable name = Status

Value = OK <------- quotes are missing

How to keep the quotes to make sure the variable is interpreted as a string and not a field name?

Tags (3)
1 Solution

Accepted Solutions
Not applicable

String variable in script

Hi,

try with this:

LOAD

    INFO,

    if(INFO='$(Status)', '$(Status)', 'KO') AS INFO2

FROM file.xlsx [...];

regards

3 Replies
Not applicable

String variable in script

Hi,

try with this:

LOAD

    INFO,

    if(INFO='$(Status)', '$(Status)', 'KO') AS INFO2

FROM file.xlsx [...];

regards

vijay_iitkgp
Valued Contributor

String variable in script

Hi,

Put your variable under quotes:

if(INFO='$(Status)', '$(Status)', 'KO') AS INFO2

Not applicable

String variable in script

It works like a charm! (I indeed got misleaded by the syntax editor coloring)

Thank you very much!