Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

limited rounding

Hi everybody!

I need to round numbers by the 19th decimal place.

In the menu of QlikView there is a possibility to round by the 14th place.

To round within the script or in a table didn't work with these numbers.

I think it will work with an if-loop, but that will only work exactly by a

repeat of a querry for each decimal place.

Somebody with an equal problem or a simpler answer?

Have a nice weekend!

11 Replies
Anonymous
Not applicable
Author

A guess but how about multiplying your number by 1,000,000,000,000,000,000,000,000, rounding it then dividing it by the same number.  I have not counted number of zeroes I typed & expect it to be wrong.

swuehl
MVP
MVP

I believe 19 significant decimal digits is not supported by the floating point format used by QV.

Probably someone from QT could tell you more, e.g.hic

Anonymous
Not applicable
Author

I tried, but this didn't work.

hic
Former Employee
Former Employee

Stefan is right. QlikView uses a 64-bit binary internally (See Double precision) and this means 14, sometimes 15, significant digits. Not more.

HIC

marcus_sommer

Rounding especially by so many decimals will be difficult: Rounding Errors and I'm not sure how many numbers and decimals qv could handle within the script - in gui it's max. 14 decimals. But you could try to display them as text. Maybe you could multiply your number with some big number, then rounding and afterwards you divide it again, something like:

round(Number * pow(10, 12)) / pow(10, 12)

If you handle it completely as text and checked the 19th decimal and replace it - it will work but I think these approach will have some other disadvantages.

- Marcus

Anonymous
Not applicable
Author

I tried to separate a first part as text and rounded the last one.

If the last part is rounded from 9 to 10 it should effect the first

part. And that ist the problem. It causes some loops to prevent

a chain when there are some '9'. Maybe for each digit.

marcus_sommer

I'm not sure if this would work at once, maybe it needs some adjustments with num() or on the syntax:

text(floor(Number) & left(subfield(Number, ',' , 2), 17) &

     mid(subfield(Number, ',' , 2), 18, 1)  + round(mid(subfield(Number, ',' , 2), 19, 1) / 10))

But in general I have doubts if it will be a good idea to handle such numbers within complex string-operations and not in a specialized tool maybe mathematica and using whose output in qv.

- Marcus

Clever_Anjos
Employee
Employee

It could be easier if you multiply by a factor (1.000.000 for example) before loading into QlikView,

Same way

1 mg -> 1 gram/1.000.000

Anonymous
Not applicable
Author

The database is from sql. Is it possible to cache transformed data before loading into QlikView without using another tool?