Skip to main content
Announcements
Applications are open for the 2024 Qlik Luminary Program. Apply by December 15 here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Lesor
Contributor II
Contributor II

Use Qlik Variable in IN clause in SQL

Hi,

Is it possible to use the variable in Qlik in SQL?

In my sample below, the result is that the output still includes Name1 .

 

SET vList = 'Name1' , 'Name2';

LOAD

FirstName, LastName

;

SQL

SELECT 

FirstName, LastName

FROM Table1

WHERE LastName NOT IN '$(vList)'

;

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer
MVP & Luminary
MVP & Luminary

The variable vList contains already the string-wrapping quotes and therefore the call of the variable doesn't have them, means the where should like:

WHERE LastName NOT IN $(vList);

View solution in original post

3 Replies
Gabbar
Creator III
Creator III

Yes it is possible

Regards, Akash Dhandhi.
If this resolves your Query please like and accept this as an answer.
marcus_sommer
MVP & Luminary
MVP & Luminary

The variable vList contains already the string-wrapping quotes and therefore the call of the variable doesn't have them, means the where should like:

WHERE LastName NOT IN $(vList);

Lesor
Contributor II
Contributor II
Author

Thanks, didn't know I have to removed the single quotes in the SQL.

Mine is now working.