Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tmap expression syntax

i have tried below expression in tmap as per expectation i should get  " null " as output in tmap test editor ..but getting  "n" as output ...could you please clarify this...

 

0683p000009M2g2.png

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

@lavan524 

 

Or try this way where the code is checking whether you are sending input itself as "null".

 

 

Relational.ISNULL(row1.data) || row1.data.trim().equals("")|| row1.data.trim().toLowerCase().equals("null")?null:row1.data.substring(0,1).toLowerCase()

 

 

But the caveat is that sending null as a string is a bad practice.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

11 Replies
manodwhb
Champion II
Champion II

@lavan524 ,that hole expression will return a single character ,let think this way you have null as string with that expression will return only n ,if you changed 1 to 3 it will return nul

Anonymous
Not applicable
Author

Hi,

 

Please try like below.

 

Relational.ISNULL(row1.data) || row1.data.trim().equals("")?null:row1.data.substring(0,1).toLowerCase() 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

i have tried this way but still getting same output 

 

0683p000009M2Xf.png

Anonymous
Not applicable
Author

Hi,

 

    Could you please print the input and output side by side to a tLogrow and share it with us? We would like to see the input data you are passing.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

manodwhb
Champion II
Champion II

@lavan524 ,do you understand my answer,if not for that column have null values as string which means "null" has took as for that column with your expression returns only one character for "null" data the first character is n,so thats why you see n 

Anonymous
Not applicable
Author

Actually i am trying  to test expression in tmap test editor ...as per expectation by default value should be null and as per expression out put should be  " null " but getting " n "


Relational.ISNULL(row1.S_Name_Indexed__c) || row1.S_Name_Indexed__c.trim().equals("")?null:row1.S_Name_Indexed__c.substring(0,1).toLowerCase()

manodwhb
Champion II
Champion II

@lavan524 ,if you want null then change this way.

 

Relational.ISNULL(row1.S_Name_Indexed__c) || row1.S_Name_Indexed__c.trim().equals("")?null:row1.S_Name_Indexed__c.substring(0,4).toLowerCase()

Anonymous
Not applicable
Author

@manodwhb  has already explained it.

 

You are trying to insert null as a string "null" or "Null" or "NULL". But as per java, if it has to consider a value as null, it should be empty like a black hole.

 

You cannot equate it with any value as string.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

@lavan524 

 

Or try this way where the code is checking whether you are sending input itself as "null".

 

 

Relational.ISNULL(row1.data) || row1.data.trim().equals("")|| row1.data.trim().toLowerCase().equals("null")?null:row1.data.substring(0,1).toLowerCase()

 

 

But the caveat is that sending null as a string is a bad practice.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂