<?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 Create field which its values are in reverse order in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105869#M27501</link>
    <description>&lt;P&gt;I have a search command and it return below results:&lt;BR /&gt;
&lt;EM&gt;[mysearch]|dedup version|fields version&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;version
11
22
33
44
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to create another field which its values are in reverse order of version as below, how can I do in search command?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;version   reverse_version
11        44
22        33
33        22
44        11
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 25 Apr 2013 09:23:17 GMT</pubDate>
    <dc:creator>cycheng</dc:creator>
    <dc:date>2013-04-25T09:23:17Z</dc:date>
    <item>
      <title>Create field which its values are in reverse order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105869#M27501</link>
      <description>&lt;P&gt;I have a search command and it return below results:&lt;BR /&gt;
&lt;EM&gt;[mysearch]|dedup version|fields version&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;version
11
22
33
44
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to create another field which its values are in reverse order of version as below, how can I do in search command?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;version   reverse_version
11        44
22        33
33        22
44        11
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2013 09:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105869#M27501</guid>
      <dc:creator>cycheng</dc:creator>
      <dc:date>2013-04-25T09:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create field which its values are in reverse order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105870#M27502</link>
      <description>&lt;P&gt;Have you looked at the &lt;CODE&gt;sort&lt;/CODE&gt; search command? Not good enough?&lt;/P&gt;

&lt;P&gt;If you really want to have original order and reverse order in separate columns in the same table, then you'll have to look at &lt;CODE&gt;appendcols&lt;/CODE&gt;;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your base search&amp;gt; | appendcols [search &amp;lt;your base search&amp;gt;| rename version as rev_version| sort -rev_version]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;a faster way would be &lt;CODE&gt;appendpipe&lt;/CODE&gt;, but your table would be skewed;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your base search&amp;gt; | appendpipe [rename version as rev_version| sort -rev_version]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps..&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2013 10:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105870#M27502</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-04-25T10:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create field which its values are in reverse order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105871#M27503</link>
      <description>&lt;P&gt;Thanks Kristian, the first search command is working! &lt;BR /&gt;
And I have to add the stats command as below:&lt;/P&gt;

&lt;P&gt;&lt;YOUR base="" search=""&gt; | dedup version | stats count by version | appendcols [search &lt;YOUR base="" search=""&gt; | dedup version | rename version as rev_version | sort -rev_version] | fields version rev_version&lt;/YOUR&gt;&lt;/YOUR&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:47:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105871#M27503</guid>
      <dc:creator>cycheng</dc:creator>
      <dc:date>2020-09-28T13:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create field which its values are in reverse order</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105872#M27504</link>
      <description>&lt;P&gt;yeah, well, that &lt;CODE&gt;stats&lt;/CODE&gt; command is part of what I meant with &lt;CODE&gt;&amp;lt;your base search&amp;gt;&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;However, you'll be running the same search twice, both in the outer and inner search (i.e. the subsearch).&lt;/P&gt;

&lt;P&gt;The second option, &lt;CODE&gt;appendpipe&lt;/CODE&gt;, operates on the results from first search, which - at least in this case - is a very small set of data (4 events).&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2013 17:43:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-field-which-its-values-are-in-reverse-order/m-p/105872#M27504</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-04-25T17:43:34Z</dc:date>
    </item>
  </channel>
</rss>

