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!

Security Professional: Sharpen Your Defenses with These .conf25 Sessions

Sooooooooooo, guess what. .conf25 is almost here, and if you're on the Security Learning Path, this is your ...

First Steps with Splunk SOAR

Our first step was to gather a list of the playbooks we wanted and to sort them by priority.  Once this list ...

How To Build a Self-Service Observability Practice with Splunk Observability Cloud

If you’ve read our previous post on self-service observability, you already know what it is and why it ...