Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
chhavi376
Creator II
Creator II

Rounding off to an integer using NUM

I was trying to round off all my numbers to integer but i came across this problem:

if i use '#,##0.00'  in num, i get these numbers:

Untitled.png

When we round this off, it should ideally be 16, 27 and 35

But when i use '#,##0'  in num, i get these numbers:

1.png

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe using a second round of integer values:

round(round(sum({<Flag={1}>} Value_N)*10),10)/10

Value_Type =Date(Date,'MMM''YY') Jul'16Jun'16May'16Apr'16Mar'16Feb'16Jan'16Dec'15Nov'15Oct'15Sep'15Aug'15Jul'15Jun'15May'15Apr'15Mar'15Feb'15Jan'15Dec'14Nov'14Oct'14Sep'14Aug'14Jul'14
Detail16181727273524181112321828292418193937403326112

View solution in original post

37 Replies
sunny_talwar

Look here for Rounding error issues in QlikView:

Rounding Errors

Nicole-Smith

Is 15.50 rounded?  If the underlying data is actually something like 15.4991, rounded to two decimal places, it would be 15.50, but the rounded integer would be 15 instead of 16.

You could also try using round() instead of num() to get the integer value.

chhavi376
Creator II
Creator II
Author

Hi Nicole,

I just checked the data in my reporting tables,

It is exact '15.5'

Untitled.png

the round function also gives me 15, if i use '1'as the offset.

Not applicable

Hey please Round()  and dont use num() inside for that

i hope it will work

saimahasan
Partner - Creator III
Partner - Creator III

Hi

Please use ceil function:

Ceil(FieldName) as FieldName

Anil_Babu_Samineni

O/P for this

LOAD Floor(Round(Value)-1) as Value INLINE [

Value

12.6

13.8

14.5

];

Value

12

13

14

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
gautik92
Specialist III
Specialist III

use round()

chhavi376
Creator II
Creator II
Author

Vijay,

As per my understanding, floor() function rounds the numbers down.

i want it to round as per the logic:

number >= x.5 gives me x+1

and number <x.5 gives me x.

and as i mentioned in the original post,

my numbers from the reporting tables were 15.5, 26.5 and 34.5

but when i round them, i get 15,27 and 35

So why is 15.5 not rounding upto 16?

I have tried using num(), round(), ceil() and now floor() as well.

But i get the same numbers-15,27,35, which are not correct

chhavi376
Creator II
Creator II
Author

Round(), Ceil(), Floor(), Num()- doesn't work!