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: 
JayZ1
Contributor III
Contributor III

Expression builder in TMAP

Hi! I need some examples of using the expression builder in TMAPs

input:

(either True or false or 0 or 1)

output:

i want is to be Active/Inactive

for every True(1) it should change it to Active

else False(0) should be Inactive

i tried this but it doesn't work for the second expression:

row1.active.equals(

"1"

)?row1.active:

"Active"

 

row1.active.equals(

"0"

)?row1.active:

"Inactive"

 

or this:

StringHandling.EREPLACE(row1.active,

"1"

,

"Active"

); 

StringHandling.EREPLACE(row1.active,

"0"

,

"Inactive"

) ; 

what are all the ways to handle this situation?

Labels (2)
2 Replies
Anonymous
Not applicable

OK. First of all you need to know the type of your "row1.active" data. If it is Boolean, then you will need something like this....

 

row1.active ? "Active" : "Inactive"

 

This is essentially saying, if row1.active is true then output "Active" otherwise output "Inactive". Because you are dealing with a boolean, you don't need to do anything but the above.

 

If row1.active is a String, you will need to do something like this....

 

row1.active.equals("1") ? "Active" : "Inactive"

 

This can also be used for "True" as well. You must make sure that the String values are exactly matched. So look out for how your values arrive.

 

If row1.active is an int, you will need to do something like this....

 

row1.active==1 ? "Active" : "Inactive"

 

The above are examples of in-line IF conditions. You can find more about these on many Java sites.

Anonymous
Not applicable

Hi,

Thank you for reaching out!

 

Please view this tMap expression syntax page where it has 9 examples: https://help.talend.com/r/en-US/7.3/tmap/tmap-expression-syntax

 

Also we have this Writing code using the Expression Builder example: https://help.talend.com/r/en-US/7.3/studio-user-guide/writing-code-using-expression-builder

 

Best,