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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
talendstar
Creator
Creator

limit float to 2 places in tmap

I am using tmap to read data from a file and load it into a table.

 

One of the columns in the text file contains values like:

0.05

0.03

etc...

 

However when Talend flow uploads the data into the table the values change from 0.05 to 0.05000000075

or from 0.03 to 0.03999999911.

 

I have tried two approached in the tmap to try to reduce the value to two decimal places so I get only values like 0.05 or 0.03:

(row6.MinIncrease == null || row6.MinIncrease.equals("")) ? 0f :
row6.MinIncrease.floatValue()

 

(row6.MinIncrease == null || row6.MinIncrease.equals("")) ? 0f :
Math.round(row6.MinIncrease*100)/100f

 

but no luck. still getting values like 0.05000000075 .

 

What can I do here so I get only two decimal places?

 

thanks

Labels (2)
13 Replies
talendstar
Creator
Creator
Author

I have turned on log4j and it prints each row of the data with correct values. Have a look at the last field below:

 

2D072|753|2536.1667|0.0|

06052|401|1801.1893|0.05|

 

 

talendstar
Creator
Creator
Author

Also tried using BigDecimal. I could get the flow to execute with BigDecimal data type. 

talendstar
Creator
Creator
Author

I have got it to work. I modified the data type in the tmap to Double for both source and destination. Even though the column data type in Snowflake is float.

 

0683p000009M5o0.png

 

Appreciate your help and support. 0683p000009MACn.png

 

Thanks

RahulKumar2
Contributor
Contributor

it will not work, even if you change at schema level