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!

Announcing Scheduled Export GA for Dashboard Studio

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

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...