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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...