<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Sort field based on sorted field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149614#M41866</link>
    <description>&lt;P&gt;So did you get a solution?&lt;/P&gt;</description>
    <pubDate>Mon, 03 Aug 2015 14:02:57 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-08-03T14:02:57Z</dc:date>
    <item>
      <title>Sort field based on sorted field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149608#M41860</link>
      <description>&lt;P&gt;Hello, I'm trying to get out a table that sorts connections by network type, and then for each connection displays the session code and session state.&lt;/P&gt;

&lt;P&gt;It's sorted over four columns from left to right: Network type, connection, connection code, connection state.&lt;/P&gt;

&lt;P&gt;As of now it sort of works, the connections are corretly listed by each network type but the corresponding connection state and code are not correct, they change at random and seems to be sorted by time of event or something rather than based on the connection.&lt;/P&gt;

&lt;P&gt;I'm looking for something like this:&lt;/P&gt;

&lt;P&gt;... | eval sessionCode=(get session code) | eval sessionState=(get session state)  | stats list(connection), (list(connectionState) by connection), (list(connectionCode) by connection), by networkType&lt;/P&gt;

&lt;P&gt;But this obviously doesn't work. How would this be possible?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 14:24:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149608#M41860</guid>
      <dc:creator>ohlafl</dc:creator>
      <dc:date>2015-07-30T14:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sort field based on sorted field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149609#M41861</link>
      <description>&lt;P&gt;With &lt;CODE&gt;stats&lt;/CODE&gt;, when you use &lt;CODE&gt;list&lt;/CODE&gt;, you get 1 entry for each occurrence (including duplicates) and it is listed in time-sequenced order but when you use &lt;CODE&gt;values&lt;/CODE&gt; you get only distinct entries (no duplicates) and it is listed in alphabetically sorted order.  Perhaps you should switch to using &lt;CODE&gt;values&lt;/CODE&gt; instead of &lt;CODE&gt;list&lt;/CODE&gt;.  Of course if you do this, you will lose the "row-ish" relationship between lists (each list of values is sorted independently).&lt;/P&gt;

&lt;P&gt;Alternatively, you could create an aggregate field and then sort based on that, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval sessionCode=(get session code) | eval sessionState=(get session state) | eval sessionCodeAndState = sessionCode . ":" . sessionState | stats list(connectionCodeAndState) by connection networkType | sort 0 connection networkType connectionCodeAndState
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2015 14:33:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149609#M41861</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-30T14:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sort field based on sorted field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149610#M41862</link>
      <description>&lt;P&gt;Switching to values does not have any impact but I guess it cannot be used the way I want to anyway.&lt;/P&gt;

&lt;P&gt;Creating an aggregate field sort of works but the concenating does not, the row switches bewteen displaying connectionCode or connectionState depending on the latest event. Any ideas on this?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 15:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149610#M41862</guid>
      <dc:creator>ohlafl</dc:creator>
      <dc:date>2015-07-30T15:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sort field based on sorted field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149611#M41863</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval sessionCode=(get session code) | eval sessionState=(get session state) | stats count by networkType connection connectionState connectionCode| stats list(connection), (list(connectionState) by connection), (list(connectionCode) by networkType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first stats will sort the events by networkType connection connectionState and connectionCode, next status will just list them so the sorting order maintained.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 15:15:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149611#M41863</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-30T15:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sort field based on sorted field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149612#M41864</link>
      <description>&lt;P&gt;Perhaps what you are looking for is not "sorting" but "nesting".  Does this look better?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval sessionCode=(get session code) | eval sessionState=(get session state) | eventstats values(connection) AS connectionsByNetworkType BY networkType | eventstats values(connectionCode) AS connectionCodesByConnection BY connection | stats first(connectionsByNetworkType) AS connectionsByNetworkType first(connectionCodesByConnection) AS connectionCodesByConnection by connection networkType
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2015 15:43:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149612#M41864</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-30T15:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sort field based on sorted field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149613#M41865</link>
      <description>&lt;P&gt;This was not the solution but it did help me to better understand the principles of running queries, thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Aug 2015 13:54:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149613#M41865</guid>
      <dc:creator>ohlafl</dc:creator>
      <dc:date>2015-08-03T13:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sort field based on sorted field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149614#M41866</link>
      <description>&lt;P&gt;So did you get a solution?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Aug 2015 14:02:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sort-field-based-on-sorted-field/m-p/149614#M41866</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-03T14:02:57Z</dc:date>
    </item>
  </channel>
</rss>

