Splunk Search

How to get only 2 decimal values without rounding?

shankarananthth
Explorer

I have the value in the field as mentioned below ..

data
1234.456
1256.445
12.456
156.446

I need the output as mentioned below.
Kindly help me to achieve it.

data
1234.45
1256.44
12.45
156.44

Thanks in advance.

Tags (2)
0 Karma

somesoni2
Revered Legend

Try this

your base search | eval data=replace(data,"(\d+\.\d\d)\d*","\1")
0 Karma

sundareshr
Legend

Try using regex. This should work (change data to fieldname of choice)

... | rex "(?<data>\d+\.\d{0,2})" 
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...