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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
DEV4
Contributor III
Contributor III

Handling multiple conditions in TMAP

Hello All,

I have been using multiple conditions in my tmap to handle two conditions. Below is the logic Im using.

 

row2.SPRIDEN_ID==null ? "Unknown" :row3.RPRATRM_USER_ID.equals("WWW_USER") ? "N/A" : row2.SPRIDEN_FIRST_NAME

 

The first condition works and Im able to see Unknown where ever there are nulls in the SPRIDEN_ID but the second condition is not working meaning Im not able to see N/A where ever there is WWW_USER.

 

Please correct me if Im missing anything in the syntax. I have attached the picture and the one highlighted in yellow should be N/A.

 

Thank You

 

0683p000009M5QB.png

Labels (2)
4 Replies
Anonymous
Not applicable

The below Java is basically saying "When SPRIDEN_ID is null, set the value to "UNKNOWN". If SPRIDEN_ID is not null AND RPRATRM_USER_ID equals "WWW_USER", set the value to "N/A". Otherwise, set the value to what is held by SPRIDEN_FIRST_NAME"

row2.SPRIDEN_ID==null ? "Unknown" :row3.RPRATRM_USER_ID.equals("WWW_USER") ? "N/A" : row2.SPRIDEN_FIRST_NAME

So, I suspect that in your example, that SPRIDEN_ID is null when RPRATRM_USER_ID is "WWW_USER"

DEV4
Contributor III
Contributor III
Author

Thanks for the reply. As you suspected, SPRIDEN_ID is not null when RPRATRM_USER_ID is "WWW_USER".

 

But I changes the expression as below and that worked. Now im able to see N/A for the WWW_USER

 

row3.RPRATRM_USER_ID.equals("WWW_USER") ? "N/A" : row2.SPRIDEN_ID == null ? "Unknown" : row2.SPRIDEN_FIRST_NAME

Anonymous
Not applicable

That is interesting. Are you sure SPRIDEN_ID was not null? The code you used could not have returned that value unless it was null.

 

The change that you have made simply changes the order in which the logic is applied. The first test is "Does RPRATRM_USER_ID equal 'WWW_USER'?". If that part of the code is true, it doesn't bother to check the rest since it knows what to do at that point. It's only if it does not match "WWW_USER" that the next condition is checked.

DEV4
Contributor III
Contributor III
Author

Sorry looks like I was not clear with the info I gave you. Below is the logic.

 

if RPRATRM_USER_ID is WWW_USER then "N/A"

 

I mean to say if RPRATRM_USER_ID is WWW_USER then no need to worry about the SPRIDEN_ID, we need to just print it as N/A.