Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Are you looking for something like this?
SET string = '"MAY,APR,MAR,FEB,JAN,DEC"';
LET strings = Replace(string,',','","');
Do I have to create a table and do a Load SubField(Field,',') as [List of Strings]?
@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?
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.
Are you looking for something like this?
SET string = '"MAY,APR,MAR,FEB,JAN,DEC"';
LET strings = Replace(string,',','","');
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.
@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));
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));