How to format

Hi everybody,

I would like to set a rule for having all the time a specific format already in knime and not only in an excel as output, This would be in order to have a clear report.

The specific problem is:

I have a number which is 12,758,242.85 and if i convert into a string will be 1.2758242850000001E7.

My final output would be like:

12’758

Thank you very much. Same would be appreciated in the case of percentage:
0.51 --> 51%

I am trying to use Data visions etc etc.

Hi @ANDREACAGNAZZI,

are the values in separate or one column? Maybe some sample data would be useful to get a better understanding of your desired outcome.

Kind regards
Mike

Hi. Am I correct to assume you would like to format numbers such that the ‘thousands separator’ should be an apostrophe instead of a comma? For example how they format numbers in Switzerland?

Here’s a quick and dirty solution using Java. (I created a metanode you can copy into your own workflow and configure). Import the attached .knwf file into your KNIME desktop explorer.
image
The metanode can be configured with the column of (double) numbers you want to format, and the formatting pattern string (see http://tutorials.jenkov.com/java-internationalization/decimalformat.html#number-format-pattern-syntax for pattern syntax). Although the thousands separator is specified with a comma in the pattern, it will be replaced with apostrophe in the output.
image
Example output:
image

custom decimal format.knwf (14.2 KB)
-Don

4 Likes

Hi there @dnaki,

nice one!

Don’t know if you know but you can share your ideas/solution/Components on KNIME Hub as well :wink:

Br,
Ivan

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.