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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Convert string to integer or float

Hi,
Do you Know an instruction to transform a string to an integer or a float in Tmap?
Thanks

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Reverse the logic suggested by @manodwhb
row1.Value != null ? row1.Value.doubleValue() : null

View solution in original post

23 Replies
Anonymous
Not applicable
Author

Hello
You can try Integer.parseInt("10") or Float.parseFloat("10.0")
Regards,
Anonymous
Not applicable
Author

Hi mhirt,
With Float.parseFloat(?10.0?), I have the following message
Expression of Var.var1 is invalid : Error on Float.parseFloat(?10.0?) => Type mismatch : cannot convert from float to String
Thanks
amaumont
Contributor III
Contributor III

Change the type of your column Var.var1 from "String" type to "float" or "Float" type and it should work 🙂
Anonymous
Not applicable
Author

Thanks amaumont
Anonymous
Not applicable
Author

Hi,
Do you Know an instruction to transform a Float or integer to a String in Tmap?
Thanks
amaumont
Contributor III
Contributor III

This is:
String.valueOf(yourValue)

or
"" + yourValue
Anonymous
Not applicable
Author

Thanks amaumont
Anonymous
Not applicable
Author

Hi all,
I have a HOME PHONE NUMBER as a STRING that I want to only get the first 3 digits (AREACODE) of and then want to convert to an INT..
Right now im using the following and getting an error:
I create a variable as so...
StringHandling.LEFT(row1.homePhoneNum,3) which is called VAR.SDHAREA(STRING)
THEN...
I map it to my output and try to convert it to an int as follows...
Integer.parseInteger(VAR.SDHAREA)

Anyone have any ideas on how to accomplish this?
Any help would be greatly appreciated!
-Chris
Anonymous
Not applicable
Author

Hi chrish:
JDK API ( http://java.sun.com/j2se/1.5.0/docs/api/) :
Class: java.lang.Integer
static int parseInt(String s)
Parses the string argument as a signed decimal integer.
you should try Integer.parseInt(VAR.SDHAREA)