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: 
Anonymous
Not applicable

Converting String to Boolean

Hi All,
How to convert string to boolean in tmap ?
Thanks&Regards
Aishu
Labels (2)
12 Replies
Anonymous
Not applicable
Author

You can use folowing code to convert -
String strBoolean = "true";

//Do the String to boolean conversion
boolean theValue = Boolean.parseBoolean(strBoolean);
System.out.println(theValue);
Anonymous
Not applicable
Author

Hi Aishu,
Could you give us more information about your requirement? Why do you want to Converting String to Boolean? Perhaps we have a better suggestion for your work design.
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi xdshi,
My requirement is source column data type is string and data like true,false
but target column data type is boolean.
I converted string to Boolean using this function
"Boolean.parseBoolean(row3.column_name) "
Regards
Aishu
Anonymous
Not applicable
Author

Hi,
If your Input is "true or false", it is totally OK. Maybe the following expression is also a good option
Boolean.valueOf(row3.column_name)

.
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi Sabrina

Just now i checked your code ,it is working fine.
thanks for your replay.
Regards
Aishu
Anonymous
Not applicable
Author

Hi Aishu,
You are welcome, and thanks your feedback. Feel free to post your issue on forum.
Best regards
Sabrina
BA621858188
Creator
Creator

Hi All,

 

I wanted to convert data type string to boolean. input data is T/F.

getting an error: Cannot convert "F" to Boolean

 

Anonymous
Not applicable
Author

Hello,

Could you please show us the function you are using? What does your expected result look like?

Best regards

Sabrina

BA621858188
Creator
Creator

Hello Sabrina,

 

@Xiaodi Shi​ 

Thank you for reply.

 

Source - T/F (datatype string) Target - T/F (Boolean)- Same value but diff datatype

I am trying to convert String data type value to boolean.

Source is DB Table where values are T/F. Tmap used for just for transformation.

using tconverttype I am doing conversion from string to boolean but getting below error:

Cannot convert "T" to Boolean

Cannot convert "F" to Boolean

Cannot convert "T" to Boolean

Cannot convert "T" to Boolean

Cannot convert "F" to Boolean

Cannot convert "F" to Boolean

Cannot convert "F" to Boolean

Please help.

Thanks