Splunk Enterprise

Count of rows with a value greater than 0

3666142
Path Finder

How do a get a count of rows that have a value greater than 0? Example below. The last column is what we are trying to generate.

Name    2024-02-06  2024-02-08    2024-02-13  2024-02-15     Count_Of_Rows_with_Data
Pablo       1          0              1          0               2
Eli         0          0              0          0               0
Jenna       1          0              0          0               1
Chad        1          0              5          0               2

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eval Count_Of_Rows_With_Data=0
| foreach 20*
    [| eval Count_Of_Rows_With_Data=if('<<FIELD>>' > 0, Count_Of_Rows_With_Data+1, Count_Of_Rows_With_Data)]

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Alternatively, without having to know the names of the fields

| untable Name Date value
| appendpipe
    [| stats count(eval(value > 0)) as value by Name
    | eval Date="Count_Of_Rows_With_Data"]
| xyseries Name Date value
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval Count_Of_Rows_With_Data=0
| foreach 20*
    [| eval Count_Of_Rows_With_Data=if('<<FIELD>>' > 0, Count_Of_Rows_With_Data+1, Count_Of_Rows_With_Data)]

3666142
Path Finder

Perfect. Thank you!

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...