Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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.
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,