Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Is round function inconsistent?

Attached is straight table that includes expressions for round function.  Seems inconsistent.

=round(1.2)           = 1

= round(1.5)          = 2

= round(1.8)          = 2

=round(1.2,1,.2)    = 1.2

=round(1.3,1,.2)    = 1.2

=round(1.4,1,.2)    = 1.2

=round(1.5,1,.2)    = 1.2   ??? why not 2.2

=round(1.6,1,.2)    = 1.2   ??? why not 2.2

=round(1.7,1,.2)    = 2.2

=round(1.8,1,.2)    = 2.2

=round(1.9,1,.2)    = 2.2

=round(1.99,1,.2)   = 2.2

Attached is .qvw.  This is likely very simple, just want to make sure I have the function straight.

Thanks,


D

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

It is working correcly.

Logic is it sets the base as 0.2,1.2, 2.2..... instead of 0,1,2

Ex:

for the case 0,1,2

0.4 is rounds to 0

0.5 is to 1

1.4 is to 1

1.7 is to 2

like the way for the case 0.2,1.2, 2.2

0.6 is to 0.2

0.7 is to 1.2 (means 0.2 + 0.5 round of starts)

1.4 to 1.2

1.8 to 2.2

Hope it helps

Celambarasan

View solution in original post

5 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

It is working correcly.

Logic is it sets the base as 0.2,1.2, 2.2..... instead of 0,1,2

Ex:

for the case 0,1,2

0.4 is rounds to 0

0.5 is to 1

1.4 is to 1

1.7 is to 2

like the way for the case 0.2,1.2, 2.2

0.6 is to 0.2

0.7 is to 1.2 (means 0.2 + 0.5 round of starts)

1.4 to 1.2

1.8 to 2.2

Hope it helps

Celambarasan

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Chnage your .2 to 0.2 e.t.c

=round(1.2)       

= round(1.5)       

= round(1.8)        

=round(1.2,1,0.2)  

=round(1.3,1,0.2) 

=round(1.4,1,0.2)   

=round(1.5,1,0.2) 

=round(1.6,1,0.2)   

=round(1.7,1,0.2)

=round(1.8,1,0.2)  

=round(1.9,1,0.2)  

=round(1.99,1,0.2) 

Regards,

Gabriel

Not applicable
Author

Gabrriel,

This made no difference.

Thanks,

D

Donald Schafer

dj.schafer@comcast.net

978-582-1523

Not applicable
Author

Ah, thanks, works for the cases but a little odd.

round(1.7, 1, .2)  = 2.2

round(1.4, 1, .2)  = 1.2

// set the new range base for round to the ones digit with offset of .2

// so it goes .2, 1.2, 2.2, 3.2, etc..  instead of 0, 1, 2, 3 etc... as the base ranges

// the middle number in this case is .7, 1.7, 2.7, 3.7, etc...

// So round of anything from .2<=x<.7 rounds down

// So round of anthing from  .7<=x<1.2 rounds up

Kind of strange but this looks likely, thanks....

Not applicable
Author

round(1.5,1,.2) means step is 1,offset is 0.2,   available numerical are:

0.2  1.2  2.2

1.5 closer to 1.2