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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
soowork
Contributor III
Contributor III

[resolved] tMap - update only if value is non-Null?

Is there a way, using tMap, to say that I only want to update a value in the output table if the matching input value is not NULL?
If the input value is non NULL, then I want to update the column. If the input value is NULL, I want to leave the existing value alone. This will vary from row to row.
I suspect this is quite simple, but I am struggling figuring it out. TIA.
Input
ID Value
1 cat
2 NULL
4 fish
Existing Table
1 kitten
2 snake
3 koala
4 turtle
5 dog

Result
1 cat
2 snake
3 koala
4 fish
5 dog
Labels (2)
11 Replies
soowork
Contributor III
Contributor III
Author

Ah, ok, I think I have it figured out.
Basically have my tMap output be
NewData.field == NULL ? ExistingTable.field : NewData.field
See the screenshot attached.
0683p000009MBgu.png
soowork
Contributor III
Contributor III
Author

(I should have said null instead of NULL. doh.)
Anonymous
Not applicable

hi!
I have used a similar solution, but when the lookup returns 0 rows, the job throws a NullPointer Exception at ExistinTable.field reference.  Any idea about this?
Thanks in advance
Anonymous
Not applicable

Hi lgtleon,
I have also tested above solution. It works perfectly fine in both case.
case I : when lookup row returns non zero row.
case II : when lookup row returns  zero row.
See screenshot. ( Note that I have created job according to first post and included case II )
 
Anonymous
Not applicable

Hi,
I am not able to upload screenshot.
Regards,
Amol
Anonymous
Not applicable

0683p000009MBi7.png
see screenshot.
Regards,
Amol
Anonymous
Not applicable

Hi again!
I have changed the expression used to verify null values
Old version => ((!((Integer)out8.idOrgPub).equals(row_existing.idOrgPub)) && (out8.idOrgPub != 0)) ? out8.idOrgPub :  row_existing.idOrgPub 
New version =>Relational.ISNULL(out8.idOrgPub) ?row_existing.idOrgPub: out8.idOrgPub 
I can´t see the difference 0683p000009MPcz.png, but with the change, it works!

Thanks a lot for your help!
Anonymous
Not applicable

Hi lgtleon,
Nice to see that you got a solution. 
And I have used below expression for a testing:
NewData.field == NULL ? ExistingTable.field : NewData.field
Regards,
Amol
_AnonymousUser
Specialist III
Specialist III

Hi,
I want to get the first non null value from a column using tmap. PLs suggest a solution.