Splunk Search

How do you sort columns within a column?

psangli
Explorer

For example

Name Code Pool
Name1 100 p1
57 p32
63 p43
230 p27

Name2 120 p2
77 p33
83 p44
250 p28

should become

Name Code Pool
Name1 230 p27
100 p1
63 p43
57 p32

Name2 250 p28
120 p2
83 p44
77 p33

Tags (2)
0 Karma

DalJeanis
Legend

If you mark your data as code, then the interface will not slam it all to the left like that.

0 Karma

woodcock
Esteemed Legend

Like this:

|makeresults | eval raw="Name1 100 p1
Name1 57 p32
Name1 63 p43
Name1 230 p27
Name2 120 p2
Name2 77 p33
Name2 83 p44
Name2 250 p28"
| makemv delim="
" raw
| mvexpand raw
| rename raw AS _raw
| rex "^(?<Name>\S+)\s+(?<Code>\S+)\s+(?<Pool>\S+)$"
| stats count BY Name Code Pool
| stats list(*) AS * BY Name

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| eval Combo=mvzip(Code, Pool)
| fields Name Combo
| mvexpand Combo
| rex field=Combo "^(?<Code>[^,]+),(?<Pool>.*)$"
| sort 0 - Code
| fields - Combo
| stats list(*) AS * BY Name

somesoni2
Revered Legend

It would've been better if you had posted your current search generating those output. Assuming that your last command was something on the lines of ..| stats list(Code) as Code list(Pool) as Pool by Name OR ..| stats values(Code) as Code values(Pool) as Pool by Name, give this a try..

your current search before the last stats
| sort 0 Name -Code 
| stats list(Code) as Code list(Pool) as Pool by Name
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 ...