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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
mgchong
Contributor III
Contributor III

Convert from BigDecimal to String

Hi guys,
My goal is to convert from source value 0.0000 (4 precision) to 0.00 (2 precision) in String format.
I noticed there is an issue when converting from BigDecimal to String. For example, my source file with value 0.0000 (I am setting it as 2 precision in BigDecimal format). Next, I am using tmap to convert it into string. (refer to my attached screen shot).
The problem is that after converting to String, the value change back to 4 precision 0.0000 instead of 0.00
Labels (2)
3 Replies
mgchong
Contributor III
Contributor III
Author

Anonymous
Not applicable

You could do this:
java.text.NumberFormat.getInstance(Locale.ENGLISH).format(Math.round(row1.my_big_decimal_value.doubleValue() * 100d) / 100d)

The precision in your input flow will not used to read / create the BigDecimal value. Length and precision are only be used if you create a table or if you use the build-in to string conversion.
mgchong
Contributor III
Contributor III
Author

Hi Jlolling,
Thanks for the information.