Splunk Search

stats count

splunk_novice99
Explorer

Hello again splunk experts

This is my current situation:-

job_no                field4
131                      string1 
                              string2

132                      string3
                              string4

|table job_no, field2, field4|dedup, job_no, field2
|stats count dc(field4) AS dc_field4 by job_no
|eval calc=dc_field4 * count

produces:-

job_no                                       field2                                        dc_field4                              calc

1316212
1326212

This all works fine.  The problem is that I also want to include the strings (string1,string2,string3,string4) in my table. 

Like this:-

job_no                                                                   field4                                                               field2       dc_field4     calc

131string1, string26212
132string3, string46212

 

Any help would be greatly appreciated,

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Tell the stats command you want the values of field4.

|fields job_no, field2, field4
|dedup job_no, field2
|stats count, dc(field4) AS dc_field4, values(field4) as field4 by job_no
|eval calc=dc_field4 * count

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Tell the stats command you want the values of field4.

|fields job_no, field2, field4
|dedup job_no, field2
|stats count, dc(field4) AS dc_field4, values(field4) as field4 by job_no
|eval calc=dc_field4 * count

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

splunk_novice99
Explorer

Perfect!  exactly what I was after.  

Many thanks.

Tags (1)
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...