
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Convert a String to a List of Strings
I have a string that looks like "MAY,APR,MAR,FEB,JAN,DEC" but I want it to be a list of strings separated on the comma so that I can pass the list as a variable into a future SQL SELECT.
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you looking for something like this?
SET string = '"MAY,APR,MAR,FEB,JAN,DEC"';
LET strings = Replace(string,',','","');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do I have to create a table and do a Load SubField(Field,',') as [List of Strings]?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@alutz54 you have string but how it is stored? Is it stored in one of the column in table? If so how does column value looks like. Do you want to create a list from that column?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I am creating a variable of the previous 6 fiscal periods so that I can use that variable to filter a future SQL SELECT. So the string is stored as a variable that I created is stored as a variable.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you looking for something like this?
SET string = '"MAY,APR,MAR,FEB,JAN,DEC"';
LET strings = Replace(string,',','","');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes! The Replace function is exactly what I was looking for. Thank you, I am very new to Qlik Sense. If I may ask one more question, I have a SQL SELECT later on in this code where I am using the above list of strings as a filter in a WHERE clause. How would I reference the strings variable? The $(strings) format is not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@alutz54 If you are going to use this string in SQL query not sure if double code works so instead try single quotes
SET string = '"MAY,APR,MAR,FEB,JAN,DEC"';
LET strings = replace(Replace(string,',',''','''),'"',chr(39));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this
LET string = 'MAY,APR,MAR,FEB,JAN,DEC';
LET strings = Chr(39) & Replace(string, ',', Chr(39) & ',' & Chr(39)) & Chr(39);
LOAD *
FROM YourTable
WHERE Month IN ($(strings));
