Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Issue with rounding

Hi all,

I'm using Qlikview v11.20.12451.0 SR7.

I'm having some trouble with numbers getting rounded down instead of up. (eg. 0.15 rounded to 0.1 instead of 0.2)

This issue can be observed by the following steps:


1. Loading an inline value of 0.15

[Data]:

load * inline
[data
0.15]
;

2. Reload and then create either of the following expressions:

  =num(sum(data),'#,##0.0')

  =round(sum(data),0.1)

3. 0.1 will be shown instead of 0.2

4. However if '0.15' is used in place of 'sum(data)', the figure will show correctly.

Is there a bug with rounding loaded data? Currently I'm working around it by multiplying my values by 1.0000000001.

Would appreciate any help, thanks!

5 Replies
Anonymous
Not applicable
Author

ecolomer
Master II
Master II

The usual rounding rule is that if it is neglected figure is 5 or greater than 5, a drive to the previous position is added, if the figure is discarded is less than 5, the previous position is unchanged.

So, if what you want is that 0.15 is used as 0.1 instead of 0.2 so you should do is use is the floor function which rounds you down.

You have these options:

ceil (0.15, 0.1) = 0.2

floor (0.15, 0.1) = 0.1

round (0.15, 0.1) = 0.2

Not applicable
Author

Thanks jsaradhi,

from the post it seems that the hexadecimal representation results in the number not being the same as the one which was originally loaded when converted back to decimal.

Hence, 0.15 when converted to hex and then back to dec would give a value of 0.149999999999... instead of 0.15, resulting in the rounding issue.

I'm unable to solve the issue though, as I cannot convert all the numbers to integers in my application.

Not applicable
Author

I think you misunderstood me, what I want is the usual rounding rule.

Currently what I'm getting is: round(0.15,0.1)=0.1; which is unexpected as I wanted the result to be 0.2.

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

Looks like a bug

It works only if loaded data has more than 2 decimals

[Data]:

load data&'1' as data inline

[data

0.15

0.152];

adding a 1 at the end doesn't impact any problem with the rounding number, but it works