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
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...