- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to replace field value by string if certain condition matched
sndpgiri
Engager
10-03-2021
01:33 AM
How do I replace a value for a field if the value is lesser than 0.02 by "Good"?
Value | Key | date |
0.02 | 1 | 1/1/2017 |
0.02 | 1 | 1/2/2017 |
0.05 | 1 | 1/3/2017 |
0.02 | 1 | 1/4/2017 |
0.02 | 1 | 1/5/2017 |
0.02 | 1 | 1/6/2017 |
Suppose the value is lesser than 0.02, I want to replace the value by string "Good"
Value | Key | date |
Good | 1 | 1/1/2017 |
Good | 1 | 1/2/2017 |
0.05 | 1 | 1/3/2017 |
Good | 1 | 1/4/2017 |
Good | 1 | 1/5/2017 |
Good | 1 | 1/6/2017 |
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ITWhisperer

SplunkTrust
10-03-2021
01:51 AM
| eval Value=if(Value<=0.02,"Good",Value)
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sndpgiri
Engager
10-03-2021
02:04 AM
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)
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ITWhisperer

SplunkTrust
10-03-2021
04:48 AM
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)
