Splunk Search

How do I rank rows based on date if I have Date field values repeating twice?

akawacz
Path Finder

Hi

Could you help me with Ranking rows? I was trying to use streamstats, but the issue here is that I have a Date repeated twice.

My data

Date         type   count
2015-08-01    A     2000
2015-08-01    B     1000
2015-07-01    A     2000
2015-07-01    B     2000

Expected result

Date         type   count  Rank_filed
2015-08-01    A     2000        1
2015-08-01    B     1000        1
2015-07-01    A     2000        2
2015-07-01    B     2000        2

Thank you

0 Karma
1 Solution

somesoni2
Revered Legend

Try this

your current search giving first output | streamstats current=f window=1 values(Date) as prev | eval Rank_filled=if(prev=Date,0,1) | accum Rank_filled

View solution in original post

0 Karma

somesoni2
Revered Legend

Try this

your current search giving first output | streamstats current=f window=1 values(Date) as prev | eval Rank_filled=if(prev=Date,0,1) | accum Rank_filled
0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

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

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...