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!

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

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 ...