Conversion problem in Column Expression

Good Day Knimers :green_heart:

I am using Column Expression node for the following case, which works very fine:

But the problem is that it changes initial value
As you can see, it adds precision 74,453 = > 74,4532900000001

Can you give an advice how to solve this issue?

Many thanks, Karlygash

Hi @Karlygash , it might have to do with the Type. It looks like you are converting to string, and you kind of don’t have choice since you might have “NA”.

Any reason why you are not using Rule Engine for that? Try to do this with Rule Engine instead. There are some unpredictable behaviour with Javascript (Column Expressions) when dealing with doubles. My guess is that the values in the Replacement columns are more decimal precision than just 74.453, but the columns shows only 74.453.

EDIT: I just did a test, and it confirms my last comment about the precisions.
Manual input for Table Creator:

Table Creator after green state:

Column Expressions that simply copies the Replacement column to new column0, which is string (same as @Karlygash scenario):

I also tested with Rule Engine, and it will be the same behaviour. It’s all about the fact that the real number is not just 74.453 and when converted to string, the real number is revealed.

You can always format the string after to keep only 74.453.


Thanks a lot for your explanation
Do you mean formatting number using string manipulation, right?

Hi @Karlygash , since you are using Column Expressions, you can just do this directly there:

if(column("Replacement") == null) {
} else {

The function .toFixed(3) will keep it at 3 decimal places.


Hi @Karlygash , just checking if that answered your question.


Hi @bruno29a,

sorry I had too many questions in Knime forum, forgot to approve your solution

Thanks a lot :green_heart:

1 Like

No problem @Karlygash , it’s more to know if it worked or not :smiley:

Thanks for confirming :slight_smile:

1 Like

thanks a lot=)
Column expression is really handy node)

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