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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

if-else logic in tmap

hi guys,
I want to implement if else logic in expression builder in tmap.If i get an input string as "TRUE" i want to make it 1 in my output csv file or else if i get "FALSE" then i want to make it as 0 or else i want to make it as null.How to acheive this via tmap.Please Reply.Thanks in advance.
Regards,
Neeraj
Labels (2)
4 Replies
Anonymous
Not applicable
Author

Hi neeraj,
You cannot use if then else explicitly in tMap, however you can use a java ternary expression. e.g. row1.field.equals("TRUE") ? 1 : 0
If you have to use if then else then use a tJavaRow or write a custom routine.
Regards,
Rick
Anonymous
Not applicable
Author

Hi,
I have tried with the same logic(row1.field.equals("TRUE") ? 1 : 0) but it is returning me only "0". please could any one help me on this?
Thanks in advance.
Regards,
Vetha.
Anonymous
Not applicable
Author

If you trying to print the value of  row1.field  what does it prints? 

I have used it number of times and it has worked everytime.
Anonymous
Not applicable
Author

Hi,
The problem is with data type. now i have changed the data type of that field as "Boolean" and it is working fine.
Thanks.
Regards,
Vetha.