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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

nullPointer exception when using >= and not when using >

Hello everyone, 

 

So I've been fighting this thing for a day and a half and have not been able to fix it, basically, I'm using a map as attached, where the lookup key is a concatenation of a string and part of an integer. However, even tho I check all values for null, if I check for a length of more than or equal to 2, i will get a nullpointerexception, this does not happen when I check for more than only, and the value is already checked and not null. Ive tried the following

Key:

row4.Parent ==null?null:row4.Color_code==null?null:StringHandling.LEN(String.valueOf(row4.Color_code))>=2?row4.Parent+StringHandling.LEFT(String.valueOf(row4.Color_code),2):"1"

 

and 

 

Key:

!Relational.ISNULL(row4.Parent)?!Relational.ISNULL(row4.Color_code)?StringHandling.LEN(String.valueOf(row4.Color_code))>=2?row4.Parent+StringHandling.LEFT(String.valueOf(row4.Color_code),2):"1":"2":"3"

 

This will work just fine but obviously would skip an important part of my data:

row4.Parent ==null?null:row4.Color_code==null?null:StringHandling.LEN(String.valueOf(row4.Color_code))>2?row4.Parent+StringHandling.LEFT(String.valueOf(row4.Color_code),2):"1"

 

 

No dice, could anybody point me in the right direction?

 

Thank you!

Labels (2)
1 Reply
manodwhb
Champion II
Champion II

@3ezzet , you will get null pointer exception when you are writing exception without handling nulls. try to use the below should not return null pointer exception. since you are taking StringHandling.LEFT of 2 ,so you need to check length more than that value like  >2 or >=3 .

 

for the below

row4.Parent ==null?nullSmiley Sadrow4.Color_code==null?nullSmiley SadStringHandling.LEN(String.valueOf(row4.Color_code))>=3?row4.Parent+StringHandling.LEFT(String.valueOf(row4.Color_code),2):"1"))