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!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...