Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

Match function with Null Values

100% helpful (1/1)
cancel
Showing results for 
Search instead for 
Did you mean: 
Sonja_Bauernfeind
Digital Support
Digital Support

Match function with Null Values

Last Update:

May 31, 2021 11:09:39 AM

Updated By:

Sonja_Bauernfeind

Created date:

Oct 19, 2017 8:53:26 AM

If we run the following piece of script into Qlik Sense:

set nullinteger='-';
load *,
if(not match(B,5),'No Match', 'Match') as Check_Not_Match,
if ( match(B,5),'Match','No Match')as Check_Match;
load*
inline [
A, B
3, 5
6, -
20, 7];


We notice that Check_Not_Match seems to be showing the wrong result when B is NULL, as shown below.

Previw of Data.png

We expected the table to look like as below.

Preview of Data 2.png

Why is this happening? How can we get the expected result?

 

The behaviour describing is correct. The match function returns NULL when the argument is NULL and the conditional applied to a NULL is always FALSE ( the NOT is part of the conditional in this case).

 

Resolution:


To solve the issue, we have to modify the script so that we also check for NULL values, as shown below.

set nullinteger='-';
load *,
if(not match(B,5),or len(B)=0,'No Match', 'Match') as Check_Not_Match,
if( match(B,5),'Match','No Match')as Check_Match;
load*
inline [
A, B
3, 5
6, -
20, 7];



 

Labels (1)
Contributors
Version history
Last update:
‎2021-05-31 11:09 AM
Updated by: