Splunk Search

Ranking Rows in a Table based on the count

kabiraj
Path Finder

I have a table containing two columns: Channel Name and Total views. I want to create another column using eval to rank these channels based on the counts of the Total Views.

e.g.

BBC Sport 1     5566     1
BBC Sport 2     3000     2
FOX HD          1134     3

and so on till the channel with least number of views.

First col - Channel Name, Second col - Total Views, Third Col - Rank. Can it be done in Splunk. Please reply.

Tags (4)
0 Karma
1 Solution

davebrooking
Contributor

You should be able to use the streamstats command to do this.

View solution in original post

stephanefotso
Motivator

Can you be more specific? Your table has 5 columns. What is the rank and how do you get it?

SGF
0 Karma

davebrooking
Contributor

You should be able to use the streamstats command to do this.

kabiraj
Path Finder

Thanks davebrooking & sc0tt.

0 Karma

kabiraj
Path Finder

Hi davebrooking. I don't want to show statistics for each event. I want to first sum up views count for a single channel using sum command, sort it in descending order and rank it from top to bottom based on the total views count for each channel.

0 Karma

sc0tt
Builder

As @davebrooking mentioned, streamstats should be able to do this your search | sort -field | streamstats count

Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...