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!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...