Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Delphines
Contributor III
Contributor III

Count the number of Wildmatch found

Hi everyone, 

I'm not sure this is the right way to put it (with count & wildmatch).

in a load script, I'm looking at character strings into a field. What I want to achieve is: if I found several specific characters strings in field1 (at least 2 among a list  + a key), then field2 = xyz.

Thanks a lot for your help!

Labels (2)
5 Replies
marcus_sommer

Maybe: rangesum(substringcount(Field, 'search1'), substringcount(Field, 'search2'), ...)

- Marcus

MarcoWedel

please post some sample values and your expected result

Delphines
Contributor III
Contributor III
Author

Hi Marcus, 

I don't understand your suggestion 😟

Hi Marco, 

I currently have an If-Then-Else loop. the Wildmatch is in it:

If(Wildmatch( field, 'string1','string2',...) , 'result1' , 

if(Wildmatch( field, 'string1','string2',...) , 'result2' , 

...

'result20')))

But actually more than 1 result could be found with the Wildmatch: the if loop generate a priority so I end up with 1 result, but I would like to understand how many results, between result1 to result20, could be found for a given element of field. So ideally I would create a new field containing the number of results (from 1 to 20).

Thanks a lot !

marcus_sommer

Wildmatch() and substringcount() does quite the same unless the output is different and wildmatch() returned the position of the first match and substringcount() counts the number of matches. If I had understood it right you wants the last. Unclear is for me if several matches from a single search-string should be counted and/or if it should happen against multiple search-strings.

However, in both cases could the suggested approach in general been used whereby some adjustments and/or additions might be needed, for example wrapping the substringcount() with sign() to get only a 0/1 result and/or multiplying it with a continuous number like 1,2,3 ... and then using rangemax() instead of rangesum() and this is again embedded with a pick() to avoid the multiple nested if-loops.

It's not really difficult - just create a few substringcount() with and without the range-functions and see what happens.

- Marcus

Delphines
Contributor III
Contributor III
Author

Hi Marcus, 

ok got it, thanks.