Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
dawgfather
Creator
Creator

WildMatch looking for a combination of a constant and a field variable

I am wondering if it is possible, and then how to do it, to use a WildMatch function but instead of just looking up a defined string, if it's possible to "wild match" on a string + variable.

Example:

I have a constant of "wideip/" that would be followed by a set of information (folder name). I can set up a WildMatch to look for '*wideip/*' but can I combine the "wideip/{Foldername}" into a search where the {FolderName} is a dimension/variable?

 

Test Scenario

FolderName = folder1

 

Datasets

1    "c:/folder1/folder2"     should result in negative (0) as it might have "folder1" in there but not "wideip/folder1"

2    "c:/wideip/folder2/folder1" should fail because "folder1" is not right next to "wideip/"

3    "c:/wideip/folder1/folder4" should pass since "wideip/" is directly followed by "folder1"

4    "c:/wideip/folder11/folder5" would technically pass since there is a "wideip/folder1" together albeit there is an extra number "1" in there following. 

 

In #4 case, if I could really search for   * 'wideip/' & {FolderName} & '/'  *   then that would eliminate #4 while showing positive for #3.

 

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

If FolderName is a variable, then perhaps this what you are looking for::

WildMatch(TestField, '*wideip/$(FolderName)/*')

If FolderName is a field, its more complex because FolderName can have multiple possible values and the solution will depend on the context of the WildMatch operation.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

This might work if FolderName is a field value and the operations are being performed at  a global level (eg a text box):

1. Create a variable, for example vSearchVals, with the leading = sign:

=Concat(chr(39) & '*wideip/' & FolderName & '/*' & chr(39), ',')

2: Use it like this:

WildMatch(TestField, $(vSearchVals))

You may be able to integrate them like this, but i haven't tested it:

WildMatch(TestField, $(=Concat(chr(39) & '*wideip/' & FolderName & '/*' & chr(39), ',')))
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
dawgfather
Creator
Creator
Author

Is there a way to declare the variable within the load statement?

I try to use the combined piece, but when it loads I get the error that the WildMatch takes at least 2 parameters and it appears as if the variable does not count as a parameter.

 

I am using IF(WildMatch(Content,$(vWideIPSearchString))=1,'Wide IP','Not Wide IP') as Test2

or the combined one of :

IF(WildMatch(Content,$(=Concat(chr(39) & '*wideip/' & (TextBetween(MapSubString('ContentsMap',Content),chr(1),chr(2))) & '*' & chr(39))))=1,'Wide IP','Not Wide IP') as Test2

 

The error in both cases is -  WildMatch takes at least 2 parameters .... "IF(WildMatch(Content,)=1,'Wide IP','Not Wide IP') as Test2 " - note the emptiness after the "Content," - as if the WildMatch is looking for something within single quotes, but the variable isn't counting.