Splunk Search

How to get a stats count by field values from my current table?

ashish9433
Communicator

Hi Team,

I have a table in Splunk which is as below

Name    Val1    Val2     Val3     Val4
abc      YES      No      Yes       No
xyz       No     Yes      Yes       No
pqr       No     Yes       No       No
mno      Yes      No      Yes      Yes

I want the result to be as count of yes & no by Name for all val1 val2.... and it should look like below

Val        Yes          No
Val1        2            2
Val2        2            2
Val3        3            1
Val4        1            3

Can anyone please help me how can i proceed to get above output.

0 Karma
1 Solution

woodcock
Esteemed Legend

Add this:

| untable Name Val YesOrNo
| stats count(eval(match(YesOrNo,"(?i)yes"))) AS Yes count(eval(match(YesOrNo,"(?i)no"))) AS No BY Val

View solution in original post

woodcock
Esteemed Legend

Add this:

| untable Name Val YesOrNo
| stats count(eval(match(YesOrNo,"(?i)yes"))) AS Yes count(eval(match(YesOrNo,"(?i)no"))) AS No BY Val

ashish9433
Communicator

Fantastic, this is what i needed! I tried so many things, but it was untable which came to rescue.

Thanks @woodcock for your quick answer.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...