Splunk Search

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

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

Tags (2)
1 Solution
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)

Path Finder

Hi jclemons,

I believe you can use round fucntion.

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

-Krishna Rajapantula

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!

#### Observability Highlights | November 2022 Newsletter

November 2022Observability CloudEnd Of Support Extension for SignalFx Smart AgentSplunk is extending the End ...

#### Avoid Certificate Expiry Issues in Splunk Enterprise with Certificate Assist

This blog post is part 2 of 4 of a series on Splunk Assist. Click the links below to see the other ...

#### Using Machine Learning for Hunting Security Threats

REGISTER NOW Seeing the exponential hike in global cyber threat spectrum, organizations are now striving more ...