Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
dvugopietro
Partner - Contributor II
Partner - Contributor II

Rounding problems

Hello.

I have some problems with the result of a rounding operation on a number.

If i put in a textbox

round(5.365,0.01). I get 5.37

Instead, if i put:

round(-5.365,0.01). I get -5.36

I expect as result -5.37 (as with a round operation in excel) instead of -5.36.

Why different result?🤔

Thanks in advance.

 

Labels (3)
3 Replies
Anonymous
Not applicable

use this:  round(-5.365,-0.01)

you need second parameter negative to round down and not up

dvugopietro
Partner - Contributor II
Partner - Contributor II
Author

Ok. but i don't know if the number is positive or negative.

I should insert an if statment. However is a strange beahviour.

if(x>0,round(x,0.01),round(x,-0.01))

Brett_Bleess
Former Employee
Former Employee

Please have a look at the following Design Blog post, I believe it should shed some light upon things for you:

https://community.qlik.com/t5/Qlik-Design-Blog/Rounding-Errors/ba-p/1468808

The partner post is correct though, things are working as expected with the negative number, as I have run across this previously and run it by engineering, and they confirmed it is as expected behavior.  Hopefully the post above will help you better understand things, and there are some suggestions on how to better handle things too, so hopefully you may find the right solution there too in order to get what you want. 

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.