Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

mikel_de
New Contributor III

Calculation error

Hello!

I am calculating the price per item by diving Value by Quantity. I decided to do this in the script and created a calculated column Price using the same expression. As you can see in the table below, the result is the same, but strangely enough, if I subtract  the new price from the old price, the result is not always 0.

Capture.PNG

This happens for only 2 out of 60 months in the analysis. What could be the reason?

1 Solution

Accepted Solutions

Re: Calculation error

Seems like rounding error to me and nothing to be concerned about as the difference is almost negligible

Rounding Errors

3 Replies

Re: Calculation error

Seems like rounding error to me and nothing to be concerned about as the difference is almost negligible

Rounding Errors

JustinDallas
Valued Contributor II

Re: Calculation error

As Sunny said, this is a rounding error and is common in most computer languages that don't have a dedicated library to head off such things like Java's Big number classes.

I would just have an epsilon of some sort in my calculation

Script:

LET(?) vZeroEpsilon  = 0.000000001;

and then in my UI:

If( abs(Column(1) - Column(2) ) < '${vZeroEpsilon}', 0 , Column(1) - Column(2) )

;

This should go far in cutting down the nonsense numbers that are less than the circumference of an atom.

mikel_de
New Contributor III

Re: Calculation error

All clear! Thank you both!

Community Browser