Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Script and text object acting differently?! Help!

I have an expression that seems to work in a text object but then doesn't when used in my script.  Can someone suggest a solution and or explanation?

Problem:
I am trying to get a list delimited by ','  inside a variable so I can use it in some sql.  

Here is the expression:

SET vMyVar =chr(39) & Concat(MY_FIELD, chr(39) & ', ' & chr(39)) & chr(39);

It blows up if you try to use LET instead of SET, but if it is copyed and pasted into a sheet object text it works fine...?

Thanks in advance for any help!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You need to use aggregation functions in the context of a table LOAD.

Try using something like this:

TMP:

LOAD chr(39) & Concat(MY_FIELD,  chr(39)&','&chr(39)  ) & chr(39) as ConcatTmp

Resident TEST;

LET vMyVar = peek('ConcatTmp',-1,'TMP');

drop table TMP;

Assuming MY_FIELD field is originating in table TEST in this sample.

View solution in original post

3 Replies
Not applicable
Author

using LET gives "script object line error" 

swuehl
MVP
MVP

You need to use aggregation functions in the context of a table LOAD.

Try using something like this:

TMP:

LOAD chr(39) & Concat(MY_FIELD,  chr(39)&','&chr(39)  ) & chr(39) as ConcatTmp

Resident TEST;

LET vMyVar = peek('ConcatTmp',-1,'TMP');

drop table TMP;

Assuming MY_FIELD field is originating in table TEST in this sample.

Not applicable
Author

Thanks! It worked great!!!