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!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...