Splunk Search

Limiting precision/decimal

pramodkumar
Path Finder

Hi,
Have scenario, when using avg() am getting values as 15.000000 but i want it as 15 without decimal, please help me.

Tags (3)
0 Karma
1 Solution

sdaniels
Splunk Employee
Splunk Employee

Use eval and the round() function.

<your search> |stats avg(whatever) as yourNumber | eval n=round(yourNumber)

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

View solution in original post

sdaniels
Splunk Employee
Splunk Employee

Use eval and the round() function.

<your search> |stats avg(whatever) as yourNumber | eval n=round(yourNumber)

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

sdaniels
Splunk Employee
Splunk Employee

This is probably better as a separate question with specific details. You can include this link to let people know you've already done some homework. Maybe you could create a macro where you pass in the values you want to round, in order to simplify the length of your search. Is the length and complexity of the search a concern?

0 Karma

sbsbb
Builder

yes but if you are making a "| chart avg(smthing) over somethingelse by something " then you have to eval each column explicitly, for me it is not possible, there must be a better way

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...