- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If one field null, populate another field with 0
cooperjaram
Engager
03-03-2020
09:40 AM
Hello Splunkers,
I have two fields that correlate. One field is hostname and another field is score. When I try to get an average of the score I get a incorrect value due to it calculating the score field even though the hostname is null and not representing anything. Is there a way to use if(isnull) or any other eval command so if hostname is null, it gives the other field the value of 0?
Thanks,
Cooper
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
to4kawa
Ultra Champion
03-03-2020
01:12 PM
your search
|stats avg(eval(if(isnull(hostname), null(), score))) as score_avg
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

skoelpin

SplunkTrust
03-03-2020
10:02 AM
Without seeing your results, it would look something like this
| eval hostname=if(isnull(score),0,'hostname')
