Splunk Search

sort fields in a column after grouping

lain179
Communicator

I have stats values(A) by B, C and then I want to sort by values of A within each group. A is a numeric value. How can I accomplish that?

I tried stats values(A) as A by B, C | sort A but that's only sorting the groups, not the values within each group in the stats.

Tags (2)
0 Karma
1 Solution

lain179
Communicator

Thanks to somesoni2

base search | stats count by A,B,C | fields - count| sort B,C,num(A) | stats list(A) by B,C

View solution in original post

lain179
Communicator

Thanks to somesoni2

base search | stats count by A,B,C | fields - count| sort B,C,num(A) | stats list(A) by B,C

lain179
Communicator

Awesome!!!! It worked. Thank you.

0 Karma

somesoni2
Revered Legend

If you're not worried about the count and just want to list values, give this a try.

your base search | stats count by A,B,C | fields - count| sort B,C,num(A) | stats list(A) by B,C

Since duplicates are already removed by first stats, list and values will return same set of data.

Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...