Splunk Search

How to replace field value by string if certain condition matched

sndpgiri
Engager

How do I replace a value for a field if the value is lesser than 0.02 by "Good"?

ValueKeydate
0.0211/1/2017
0.0211/2/2017
0.0511/3/2017
0.0211/4/2017
0.0211/5/2017
0.0211/6/2017

 

Suppose the value is lesser than 0.02, I want to replace the value by string "Good"

 

ValueKeydate
Good11/1/2017
Good11/2/2017
0.0511/3/2017
Good11/4/2017
Good11/5/2017
Good11/6/2017
Labels (4)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval Value=if(Value<=0.02,"Good",Value)
0 Karma

sndpgiri
Engager

I get this error: 
Error in 'eval' command: Type checking failed. The '<=' operator received different types.

When I use a single quote outside the value, I get No result

 

| eval Value=if(Value<='0.02',"Good",Value)

 

 
 
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It is Value that you need to convert to a number for the numeric comparison to work not converting the number to a string

| eval Value=if(tonumber(Value)<=0.02,"Good",Value)
0 Karma
Get Updates on the Splunk Community!

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2025 SplunkTrust is officially open! If you ...

Splunk Answers Content Calendar, June Edition II

Get ready to dive into Splunk Dashboard panels this week! We'll be tackling common questions around ...

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...