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!

.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 ...