19 May 2022

The Qlik Wildmatch() function

Share this message
Learn everything about the WildMatch() function in Qlik Sense and QlikView

Every Friday at Bitmetric we’re posting a new Qlik certification practice question to our LinkedIn company page. Last Friday we asked the following Qlik Data Architect certification practice question about the Qlik WildMatch() function:

The dataset from Figure 1 has been loaded. What are the contents to be found after using the following expression: =WildMatch(Country, '*Land')?

The correct answer is D: Finland, New Zealand and Poland

Many times you will have to do some form of data transformation to deliver the required results. And in many of those times you will probably find yourself using Subfield(), see Qlik prep question 16 😉, or in this instance Wildmatch().

Wildmatch() is a great tool to find values in a field containing a certain word or having to match a certain string. And while on the surface using Wildmatch() seems pretty straightforward there are still some things to consider or know when using this syntax:

  • Wildmatch() may use wildcard characters:
  • An asterisk (*) will match any number of characters in front of or after the search string. In the question we are looking for any number of characters before Land. Since we are looking for *Land in the example and not *Land* we have not gotten The Netherlands as a result, since we are not looking for Lands.
  • A question mark (?) will match any single character on the place of the question mark. If in this example we would have given the expression Wildmatch(Country, ‘??Land’) the only result would have been Poland.
  • Wildmatch() is case insensitive. As we see in the question example we are looking for ‘Land’, with an upper case L, however the results we get are all where the ‘land‘ part is written with a lower case L.

Did you also know that:

  • Wildmatch() is also a great way to do custom sorting. Sometimes the standard numerically or alphabetically sorting options within Qlik are still not going to work. Take clothing sizes for example. If we would sort those alphabetically we would get L, M, S, XL while S, M, L, XL would be more logical for the viewer. By disabling all other sorts and using sort by expression, we can use =Wildmatch(Sizes, ‘S’, ’M’, ’L’, ’XL’) to fix a custom sorting in place.
  • Wildmatch() also returns a numerical value. This is best explained visually by loading the sizes example:
Example of the WildMatch() function

As we can see in this small example Size S receives a value of 1, since it is the first value we are looking for in the Wildmatch() statement. Then the same goes for M, which is 2, L is 3 and XL is 4. And this comes in handy for example in a load statement. Let’s refer back to the question and the countries. What would happen in the following load statement?

We will not load Netherlands at all. Since by using Wildmatch() the other countrues will receive a value of 1 for the Wildmatch() statement and since that is bigger than 0 they are being loaded. Meanwhile Netherlands will not be loaded since it hasn’t received a numerical value.

Wildmatch(), at a first glance a simple syntax, but is has many possibilities.

That’s it for this week. See you next Friday?

Masters Summit for Qlik. Advanced Qlik training

Take your Qlik skills to the next level!

If you enjoy Qlik, you’ll love the Masters Summit for Qlik. 3 days of Qlik deep dives, peer networking, ready to use resources and much more! See you there!

Test your Qlik knowledge!

Check out the Friday Qlik Test Prep archive for more Qlik questions and answers.

Friday Qlik Test Prep Functions Solution

How can we help?

Feel free to contact us if you have any comments or questions.