<?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: How to compare last value with the second last value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262288#M176894</link>
    <description>&lt;P&gt;Maybe a combination of tail and delta? Assuming the fieldname of the column was "val":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup test.csv | tail 2 | delta val as delta | eval output=case(delta&amp;lt;0,"GREATER",delta&amp;gt;0,"LESSER",true(),"EQUAL") | fields output | tail 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hth,&lt;BR /&gt;
Kai.&lt;/P&gt;

&lt;P&gt;edit: damn, 32secs late... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2016 12:54:03 GMT</pubDate>
    <dc:creator>knielsen</dc:creator>
    <dc:date>2016-08-31T12:54:03Z</dc:date>
    <item>
      <title>How to compare last value with the second last value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262286#M176892</link>
      <description>&lt;P&gt;Say I have a column with 5 records in it&lt;BR /&gt;
88&lt;BR /&gt;
22&lt;BR /&gt;
67&lt;BR /&gt;
44&lt;BR /&gt;
55&lt;/P&gt;

&lt;P&gt;I want to compare the last record 55 with that of second last value and want to write whether the value was 'greater' or 'smaller' in the output.&lt;/P&gt;

&lt;P&gt;In above case 55 was greater so my output should say GREATER. Do we have any command to accomplish this?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 06:22:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262286#M176892</guid>
      <dc:creator>ariyazudeen</dc:creator>
      <dc:date>2016-08-31T06:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare last value with the second last value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262287#M176893</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | tail 2 | delta field as difference | eval greater=if(difference&amp;gt;0, "Yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | delta field as difference | reverse | eval greater=if(difference&amp;gt;0, "Yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2016 12:53:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262287#M176893</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-31T12:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare last value with the second last value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262288#M176894</link>
      <description>&lt;P&gt;Maybe a combination of tail and delta? Assuming the fieldname of the column was "val":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup test.csv | tail 2 | delta val as delta | eval output=case(delta&amp;lt;0,"GREATER",delta&amp;gt;0,"LESSER",true(),"EQUAL") | fields output | tail 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hth,&lt;BR /&gt;
Kai.&lt;/P&gt;

&lt;P&gt;edit: damn, 32secs late... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 12:54:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262288#M176894</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2016-08-31T12:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare last value with the second last value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262289#M176895</link>
      <description>&lt;P&gt;Can you explain how this above query works. It is working but I'm not sure how if you compare (output=case(delta&amp;lt;0,"GREATER",delta&amp;gt;0,"LESSER",true(),"EQUAL") with Zero value it is giving the desire result.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 04:46:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262289#M176895</guid>
      <dc:creator>ariyazudeen</dc:creator>
      <dc:date>2016-09-01T04:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare last value with the second last value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262290#M176896</link>
      <description>&lt;P&gt;I got it now. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 05:14:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-last-value-with-the-second-last-value/m-p/262290#M176896</guid>
      <dc:creator>ariyazudeen</dc:creator>
      <dc:date>2016-09-01T05:14:44Z</dc:date>
    </item>
  </channel>
</rss>

