Splunk Search

How to sort my table columns?

Engager

Can someone help in sorting table columns. Table contains
Row1,Row2,Row3,Row11,Row22,Row33
I tried sorting in order. but it shows below

Row1
Row11
Row2
Row22
Row3
Row33

Result should be -
Row1
Row2
Row3
Row11
Row22
Row33

Thanks

Tags (3)
0 Karma
1 Solution

Contributor

Hi,

One way you could sort this, would be to extract the number from the field containing "Row" and then sort by that number.

For example, assuming your "Row" field is called "row_no":

| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

If you didn't want the "sort" field afterwards, you could then remove it with:

| fields - row_sort

To see a full example, try this:

| makeresults
| fields - _time
| eval row_no=mvrange(1,34) | mvexpand row_no | eval row_no="Row".row_no
| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

Hopefully that will get you the result that you're looking for.

View solution in original post

Contributor

Hi,

One way you could sort this, would be to extract the number from the field containing "Row" and then sort by that number.

For example, assuming your "Row" field is called "row_no":

| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

If you didn't want the "sort" field afterwards, you could then remove it with:

| fields - row_sort

To see a full example, try this:

| makeresults
| fields - _time
| eval row_no=mvrange(1,34) | mvexpand row_no | eval row_no="Row".row_no
| rex field="row_no" "Row(?<row_sort>\d+)"
| sort + row_sort

Hopefully that will get you the result that you're looking for.

View solution in original post

Communicator

What is your query?

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!