Splunk Search
Highlighted

How do you sort columns within a column?

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
Highlighted

Re: How do you sort columns within a column?

SplunkTrust
SplunkTrust

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
Highlighted

Re: How do you sort columns within a column?

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
Highlighted

Re: How do you sort columns within a column?

SplunkTrust
SplunkTrust

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

0 Karma