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!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...