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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
jensej
Creator
Creator

[resolved] Always two decimals in my int .##

Hi there
I have a column (Int) with prices in my db that looks like this
2290
500
1300
I need too make them
22.90
5.00
13.00
In tmap i just put the preis/100 as a double but then i get
22.9
5.0
13.0

How can i make it like i want, i dont need to round or anything just put a . two steps to the left from the last number.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Ah OK. Try this.....

(new java.text.DecimalFormat("0.00")).format(((double)row1.intColumn/100))

View solution in original post

4 Replies
Anonymous
Not applicable

I assume you are outputting these numbers as a string. If you are supplying them as numbers, the format is of little consequence apart from to humans. So this solution is intended for converting the numbers before output as String.
You can either create a routine wrapper for this (preferable) or use it as I demonstrate it below....


(new java.text.DecimalFormat("0.00")).format((row1.intColumn/100))

 
What I am doing is setting a format of a number with 2 decimal places ("0.00") using the DecimalFormat class. This can go into a tMap column expression or into a routine.
jensej
Creator
Creator
Author

rhall_2.0 wrote:
I assume you are outputting these numbers as a string. If you are supplying them as numbers, the format is of little consequence apart from to humans. So this solution is intended for converting the numbers before output as String.
You can either create a routine wrapper for this (preferable) or use it as I demonstrate it below....


(new java.text.DecimalFormat("0.00")).format((row1.intColumn/100))

 
What I am doing is setting a format of a number with 2 decimal places ("0.00") using the DecimalFormat class. This can go into a tMap column expression or into a routine.

Format looks good now but values like 2854 changes to 28.00 and 3972 to 39.00. I need to have them 28.54 and 39.72
Anonymous
Not applicable

Ah OK. Try this.....

(new java.text.DecimalFormat("0.00")).format(((double)row1.intColumn/100))
jensej
Creator
Creator
Author

rhall_2.0 wrote:
Ah OK. Try this.....

(new java.text.DecimalFormat("0.00")).format(((double)row1.intColumn/100))


Perfect, thanks mate!