Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Zen_Not_On
Contributor II
Contributor II

Load treating Variable in Wildmatch with double ''

Hello, i recently have started using Qilk and am trying to the a hang of it.

I am facing an issue with Wildmatch when I run the load commmand. 

I have an list of company names .csv which I am trying to match against names in qvd.

I create a variable which wraps all of entries in .csv resulting in: '*name*',

after which i use it when i load the db data in if statement , IF(WILDMATCH(UPPER( Db_name), $(list)),Db_name, 'n/a')

when i run the debug it  works fine, when i try to load it automatically wraps everything in double quotes like ''*name*'', thus failing the query, any better ideas how to tackle this. PS yes i only have names to work of so am unable to create any joins 

Labels (2)
1 Solution

Accepted Solutions
marcus_sommer

IMO the quoting-interpretation creates more challenges as it solved. If an unique field-delimiter exists it should be disabled - and if not the load of the data needs a more or less expensive special treatment (it's not specifically related to Qlik else nearly all tools struggle with it by using (old) standard-libraries from Windows).

Like hinted try to replace it with 'no quotes' - Quotes | Qlik Cloud Help 

View solution in original post

8 Replies
Zen_Not_On
Contributor II
Contributor II
Author

Ps in variable statement i have tried to use both chr(39) and just ' and as soon as i add them i do not get any in load statement

 

marcus_sommer

How is the variable created? I think that something like this:

t: load concat(Field, , '*'',''*') as Field from csv; // single quote masked by single quote
let v = peek('Field', 0, 't');

load *, if(wildmatch(Field, '*$(v)*'), 'x', 'y') as Match from XYZ;

should be working.

Zen_Not_On
Contributor II
Contributor II
Author

temp_wild:
load Concat('*''' & pattern & '*''' ,',' ) as wildlist RESIDENT Names;
let vwildlist = Peek('wildlist', 0, 'temp_wild');

also tried 

let vwildlist = '';
for i = 0 to NoOfRows('Names') - 1
let vwildlist = '$(vwildlist)' &
                    if ( i> 0, ',','')&
                  '''*'& peek('pattern', i, 'Names')& '*''';
next 
 
when i leave just the '*' & pattern & '*' load function creates list in if without any quotes 
marcus_sommer

There are different ways to create the list + assigning the result to a variable + calling the variable again - and all parts must be suitable to each other because the content-type and the specific context will have an impact if the final result is valide or not - and the above of isn't:

Concat('*''' & pattern & '*''' ,',' )

Sounds more complex as it is - ideally the above isn't developed within the origin logic else as a dummy (maybe within a separate app) within an inline-load and then showing the field(s) in a table-box. Quickly are n attempts done to move/add commas, wildcards, quotes and so on - until it looked as if it has been manually written.

Like hinted in the above suggestion I tend to create an incomplete list and adding the missing start/end of a valid list within the call of the variable - which minimized the extra efforts to add them to the field-content or around the aggregation and/or counting-methods within any loop-approaches. 

Zen_Not_On
Contributor II
Contributor II
Author

fair enough, but still does not solve the issue that as soon as i try to load the data it wraps the whole thing in an extra set of quotes ' 

PS the wildmatch search is as complex as i need it because the data i work with is garbage... 

marcus_sommer

The only aspect in which I experienced an auto-quoting to existing quotes is when the data are loaded as txt from a csv or from_field and within the file-format statement is any msq activated. If this is your scenario you may try to replace it with 'no quotes'.

You may also consider a different way which may be a mapping like:

m: mapping load Field, '< Match >' from X;

t:
load *, if(wildmatch(Check, '< Match >'), Field, 'n/a') as Field_N;
load *, mapsubstring('m', Field) as Check from Y;

Zen_Not_On
Contributor II
Contributor II
Author

Hey, you are correct when I upload the .csv file it converts it to txt, if I understand it correctly 

FROM [lib://AttachedFiles/names.csv]
(txt, utf8, embedded labels, delimiter is ';', msq)

the issue is that as soon as i remove the quotes from the variable, then qlik also does not add any automatically resulting in *names*, 

marcus_sommer

IMO the quoting-interpretation creates more challenges as it solved. If an unique field-delimiter exists it should be disabled - and if not the load of the data needs a more or less expensive special treatment (it's not specifically related to Qlik else nearly all tools struggle with it by using (old) standard-libraries from Windows).

Like hinted try to replace it with 'no quotes' - Quotes | Qlik Cloud Help