Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
euriss_sow
Partner - Contributor III
Partner - Contributor III

Round the resut to two decimal

Hey Guys, 

I am facing an issue on trying to fix my client data.

Here is the formula:

round(colA * colB / 100,0.01)

So I am expected to get my result in two decimals.

But this is what I get from Round function.

euriss_sow_1-1616316784180.png

 

anything ends with 9, round-up work unexpected.

 

 

 

Labels (1)
  • SaaS

1 Solution

Accepted Solutions
MayilVahanan

HI @euriss_sow 

Might be, this link helps you.

https://community.qlik.com/t5/QlikView-App-Dev/Round-function-giving-sometimes-incorrect-results/td-...

ex: Round(0.595+ 0.0000000001,0.01)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

8 Replies
joaopaulo_delco
Partner - Creator III
Partner - Creator III

Hi @euriss_sow !

    Try this 

num(ori_result,'#,##0.00') as result_new,
Help users find answers! Don't forget to mark a solution that worked for you!
marcus_sommer

Qlik used a binary number-system. This means that many decimal-numbers haven't an exact binary equivalent. In your case the number 0.595 isn't available else the binary of it is a bit smaller and probably like this: 0.594970703 which then leads to your seen rounding. It's not really wrong.

- Marcus

 

 

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

One workaround is to perform rounding before division.

The expression should look like this :

round(colA*colB)/100

 

Thanks and regards,
Arthur Fong

euriss_sow
Partner - Contributor III
Partner - Contributor III
Author

Hi Marcus,

The figure is exact 0.595.

euriss_sow
Partner - Contributor III
Partner - Contributor III
Author

HI @joaopaulo_delco 

this I have tried before, I can get as two decimals but if I reuse this column for calculation. it will still count as 0.595.
marcus_sommer

Not really, see: Rounding Errors - Qlik Community - 1468808

- Marcus

MayilVahanan

HI @euriss_sow 

Might be, this link helps you.

https://community.qlik.com/t5/QlikView-App-Dev/Round-function-giving-sometimes-incorrect-results/td-...

ex: Round(0.595+ 0.0000000001,0.01)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
euriss_sow
Partner - Contributor III
Partner - Contributor III
Author

We have tested with this formula

 

round(11.9*(5/100),0.01) = 0.60

round(11.9*5/100,0.01) = 0.59

 

what is the difference here?