Splunk Enterprise

How do I find a number of non-null values and put them in a column?

mistydennis
Communicator

I have a search that pulls values for 5 fields, some of which have a value and some that are null. I would like to create a new column ("totalrev") that counts the number of non-null values.

| inputlookup foo 
| search  field1=* OR field2=* OR field3=* OR field4=* OR field5=* 
| table field1, field2, field3, field4, field5, totalrev

How do I get a number into the "totalrev" column that will count the number of non-null values found in fields 1 - 5?

Tags (1)
0 Karma
1 Solution

tomawest
Path Finder

I think you would get it using the following statement above your table

eval totalrev=mvcount(mvappend(field1,field2,field3,field4,field5))

View solution in original post

tomawest
Path Finder

I think you would get it using the following statement above your table

eval totalrev=mvcount(mvappend(field1,field2,field3,field4,field5))

mistydennis
Communicator

Yes! That's what I needed - thank you so much!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...