I have two multivalue fields that are obtained off JSON object.
One field has Name, one field has (numeric) Value.
I'd like to sort base off NUMERIC values of the Value field, not Lexicographical order, and table name and value fields by highest numeric value first.
Is there a way to do this in Splunk?
If the value is numeric then sorting on the field will be done numerically. You can use tonumber()
to force a value to be converted to a number.
Sorting is done with the sort
command. Use the -
operator to specify descending order.
... | eval valueField = tonumber(valueField) | sort - valueField | table nameField valueField
If the value is numeric then sorting on the field will be done numerically. You can use tonumber()
to force a value to be converted to a number.
Sorting is done with the sort
command. Use the -
operator to specify descending order.
... | eval valueField = tonumber(valueField) | sort - valueField | table nameField valueField
Thank you. However, tonumber function does not seem to work on a multivalue field.
Apologies for overlooking that part of your question. The mvsort
function is strictly lexicographic so to sort any other way will require using mvexpand
so you have a single-value field.
Thank you! Yes, have to use mvexpand before I can work with numeric sorting.