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: 
_AnonymousUser
Specialist III
Specialist III

Format of decimal number

Hello:
I need convert some numbers, from a BD in format double, to a XML file. I need than the number has two decimals. How can I do, when the original number is 0? I only get the result 0.0, but I need 0.00
Another example of the same problem: when I pass the number 8.36 to SML, I need six decimals, and so I need 8.360000
Greetings Thanks
Jose
Labels (3)
5 Replies
Anonymous
Not applicable

With java jobs, you can use the java class "DecimalFormat" in a tJavaRow :
DecimalFormat myFormat = new DecimalFormat("0.00");
rowX.myFormattedDate = myFormat.format(rowX.myNumericRow);
_AnonymousUser
Specialist III
Specialist III
Author

Thank you for the answer, but...
I need put this code in the "expression Builder", in a component tMap. In this place, it don't work,it say "syntax error". I think than I could use a direct function to became the result. Some idea??
Greetings
Anonymous
Not applicable

Hello
in a component tMap. In this place, it don't work,it say "syntax error"

Write these code in a routine, then call the routine on tMap.
Best regards

shong
_AnonymousUser
Specialist III
Specialist III
Author

Thank you for the answer.
If I wat to use a conditional sentence, can I used some function in a tMap, or I must add this conditional sentence in a routine too?
I think, for example:
if field1 == Y
"ELECTRONIC"
else
POSTAL
Greetings
Anonymous
Not applicable

hello,
you can use this in a tMap expression field :
1) Y, POSTAL and field1 are var : field1 == Y ? "ELECTRONIC" : POSTAL
2) Y, POSTAL are String : "Y".equals(field1) ? "ELECTRONIC" : "POSTAL"