Splunk Search

How to round a decimal up to the nearest whole number?

jclemons7
Path Finder

Hello.. is there anyway to round a decimal UP to the nearest whole number? (e.g.. I would like 0.1 to be 1, 8.00001 to be 9, 8.56 to be 9 etc..)

1 Solution

yannK
Splunk Employee
Splunk Employee

look at the ceiling function, it rounds up.

http://docs.splunk.com/Documentation/Splunk/6.2.6/SearchReference/CommonEvalFunctions

ceil(X), ceiling(X)
This function rounds a number X up to the next highest integer.
This example returns n=2:
... | eval n=ceil(1.9)

View solution in original post

krishnarajapant
Path Finder

Hi jclemons,

I believe you can use round fucntion.

round(fieldname,2) here 2 is for 2 decimal points.

In your case round(fieldname,0)

-Krishna Rajapantula

yannK
Splunk Employee
Splunk Employee

look at the ceiling function, it rounds up.

http://docs.splunk.com/Documentation/Splunk/6.2.6/SearchReference/CommonEvalFunctions

ceil(X), ceiling(X)
This function rounds a number X up to the next highest integer.
This example returns n=2:
... | eval n=ceil(1.9)

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...