Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Don't miss the upcoming Q&A with Qlik session on Qlik Application Automation on November 16th! REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
euriss_sow
Partner
Partner

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 (2)
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

View solution in original post

8 Replies
joaopaulo_delco
Partner
Partner

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
MVP & Luminary
MVP & Luminary

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
Partner

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
Partner
Author

Hi Marcus,

The figure is exact 0.595.

euriss_sow
Partner
Partner
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
MVP & Luminary
MVP & Luminary

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

View solution in original post

euriss_sow
Partner
Partner
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?