Splunk Search

implement excel countif function in Splunk

Chandras11
Communicator

Hi All,

Following is my source table (pelase consider the first 2 fields:- Value and Root_Value only):- alt text

I want to find the count of values based on root values and store it a new field Count_Root_Values.The output should look like this
alt text

In excel, there is formulla for it :- =IF(COUNTIF(B$2:B2; B2)=1;COUNTIF(B:B; B2);TEXT(;)) .
In Splunk, I am trying to use the eval to generate the new field and stats count(Value) by ROOT_Value to find the number. But I really missing the iterative process to fin the count only once.

0 Karma
1 Solution

FrankVl
Ultra Champion

Try:
| stats count as Count_Root_values by ROOT_value

If you want to keep the original data as well, you could try eventstats instead of stats. But that will not give you the exact result from your example, as it will put the count on each row. Why exactly is that a problem?

View solution in original post

FrankVl
Ultra Champion

Try:
| stats count as Count_Root_values by ROOT_value

If you want to keep the original data as well, you could try eventstats instead of stats. But that will not give you the exact result from your example, as it will put the count on each row. Why exactly is that a problem?

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...