Discussion Board for collaboration on QlikView Scripting.
I'm trying to compare a variable to match a list, something like 'IN' in SQL.
How do I create a variable containing a list, and how to I compare a certain variable with 1 string to the list variable and check whether it is in the list.
is this correct?
let vTest = '1;2;3';
let vTemp= '1';
if match ('$(vTemp)','$(vTest)') then
Your list of values in the match functions needs to be delimited by a comma, and you need to take care of quotation when comparing strings.
So this should work:
Set vTest = "'Aa','B','C'";
Set vTemp= "'Aa'";
IF Match ($(vTemp),$(vTest)) then
You can do this with
If index(vTest, vTemp) > 0 Then
If index(';' & vTest & ';', ';' & vTemp & ';') > 0 Then //(exact matches)
But if you need to use match, then:
let vTemp = '1';
Let vList = chr(39) & Replace(vTest, ';', chr(39) & ',' & chr(39)) & chr(39);
If Match(vTemp, $(vList)) Then
Note that there are NO quotes in the Match expression, they have been added beforehand (chr(39))
The list is created by a load script in which I add to this list ID numbers from a table.
LOAD concat(RUN_ID,',') as RUN_IDList
from 'c:\DATA_TABLE.qvd' (qvd)
Any recommendations to this list creation? and to the match function?
Try with WildMatch function like below:
if WildMatch('$(vTemp)','$(vTest)') then