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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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