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!

.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 ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...