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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...