Splunk Search

how to show Value with individual count

Bhargav99
New Member

Hello Folks I am new to plunk please help me out of this I need Value with its individual count shown next to it .
I wrote this query

index=* sourcetype=my _sourcetype tag_type = AGENTID_COMPLETED User_Id="*"|dedup agentId | stats values(device_type_list) AS device_list,count AS "# of devices" by User_Id | eval device_list =mvjoin(device_list,",")



User_Id           | device_list | # of devices
x@gmail.com         WIN           1
ami@gmail.com       WIN           1
apea@gmail.com      WIN           3
bbir@gmail.com      LINUX         1
bmci@gmail.com      WIN           7
dn@gmail.com        LINUX         1
dslev@gmail.com     WIN           2
ee@gmail.com        LINUX,WIN     14   .................. I need as         LINUX(4), WIN (10)
fburr@gmail.com     WIN        2
fkong@gmail.com     WIN           3
gann@gmail.com      WIN           1
glyel@gmail.com     WIN           1
jlau@gmail.com      LINUX, WIN    7  ..................I need as         LINUX(4), WIN (10)

Thank you

Tags (4)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this

index=* sourcetype=my _sourcetype tag_type = AGENTID_COMPLETED User_Id="*"|dedup agentId | stats count by User_Id device_type_list | eval device_type_list=device_type_list."(".count.")" | stats values(device_type_list) AS device_list,sum(count) AS "# of devices" by User_Id | eval device_list =mvjoin(device_list,",")

View solution in original post

0 Karma

somesoni2
Revered Legend

Try this

index=* sourcetype=my _sourcetype tag_type = AGENTID_COMPLETED User_Id="*"|dedup agentId | stats count by User_Id device_type_list | eval device_type_list=device_type_list."(".count.")" | stats values(device_type_list) AS device_list,sum(count) AS "# of devices" by User_Id | eval device_list =mvjoin(device_list,",")
0 Karma

Bhargav99
New Member

seems perfect !!!!!! Only will try to remove the count for the single ones. Thank you so much!!!!!!!

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Replace your stats with this:

... | stats count as "# of devices" by User_Id device_type_list | rename device_type_list as device_list
0 Karma

Bhargav99
New Member

Hey I tried This but I need unique User Id to be shown in same record.

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Reprocessing XML into Fixed-Length Events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...