3 Replies Latest reply: Feb 20, 2018 6:24 PM by David Forest RSS

    Qlik Sense how to round 0.5 down to 0

    Casey Marincin

      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.