Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
skyline01
Creator
Creator

Qlik Sense how to round 0.5 down to 0

I am working in Qlik Sense Enterprise 3.2.  I have some numbers that I need to round by a non-standard rule.  Typically, if the decimal portion of a number is >= 0.5, then the rule is to round up to the next whole number; else, round down.  However, I have a different rounding rule in my particular situation.  If the decimal portion of a number is <= 0.5, then round down; else, round up.  So, for example...

0.5 becomes 0

2.5 becomes 2 (not 3)

2.4 becomes 2

2.6 becomes 3

3.5 becomes 3 (not 4)

How can I implement this rounding rule in my load script?  The round function in Qlik Sense doesn't let you control the rule (only the increment and offset), and ceiling / floor are not the rounding behavior that I want.  I'm thinking floor the original number to trim off the integer portion, implement some if-then logic on the decimal portion (returning 0 or 1), and then add the result of the if-then logic to the integer portion of the number.  But, I'm not sure if this is the best approach.

1 Solution

Accepted Solutions
isingh30
Specialist
Specialist

Please try like this -

round(0.5,-1) as ...

Thank you!

View solution in original post

3 Replies
isingh30
Specialist
Specialist

Please try like this -

round(0.5,-1) as ...

Thank you!

Digvijay_Singh

Not sure but this gives the result as you needed -

=Round(3.5,-1) 

dwforest
Specialist II
Specialist II

What about Round (x -0.1,1)

Simply subtract 1/10th?