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!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...