<?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 calculate the difference between the first and the last row for each page in search results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479540#M134396</link>
    <description>&lt;P&gt;Then you should use exact field names:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats first(ANJ) as first_ ANJ, last(ANJ) as last_ ANJ,  first(JFJ) as first_ JFJ, last(JFJ) as last_ JFJ, .....
| foreach ANJ, JFJ, YFYU,......
     [ eval diff_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = last_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; - first_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;] 
| table Date, ANJ, JFJ,YFYU,FFJH,FYFUY, diff_*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Apr 2020 07:04:09 GMT</pubDate>
    <dc:creator>manjunathmeti</dc:creator>
    <dc:date>2020-04-23T07:04:09Z</dc:date>
    <item>
      <title>How to calculate the difference between the first and the last row for each page in search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479536#M134392</link>
      <description>&lt;P&gt;My search produced the following CSV:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date Page_1      Page_2       Page_3       Page_4        Page_5        Page_6....
1-Jan      1       2           3            4            5            6
2-Jan      10       20           3            4            5            6
..
..
..
22-Apr      100       200           3000           7654            86895           76476
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I calculate the difference between the first and the last row for every page? Please help.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 17:26:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479536#M134392</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2020-04-22T17:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between the first and the last row for each page in search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479537#M134393</link>
      <description>&lt;P&gt;Hi @reverse,&lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats first(Page*) as first_Page*, last(Page*) as last_Page* 
| foreach Page* 
    [ eval diff_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = last_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; - first_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;] 
| table Date, Page*, diff_Page*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="Date,Page_1,Page_2,Page_3,Page_4,Page_5,Page_6
1-Jan,1,2,3,4,5,6
2-Jan,10,20,3,4,5,6
22-Apr,100,200,3000,7654,86895,76476" 
| multikv forceheader=1 
| eventstats first(Page*) as first_Page*, last(Page*) as last_Page* 
| foreach Page* 
    [ eval diff_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = last_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; - first_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;] 
| table Date, Page*, diff_Page*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 19:07:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479537#M134393</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-04-22T19:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between the first and the last row for each page in search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479538#M134394</link>
      <description>&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 02:23:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479538#M134394</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2020-04-23T02:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between the first and the last row for each page in search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479539#M134395</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/129090"&gt;@manjunathmeti&lt;/a&gt; .. what if there is no pattern in the first row ...&lt;/P&gt;

&lt;P&gt;rather than Page_1      Page_2       Page_3       Page_4        Page_5        Page_6....&lt;/P&gt;

&lt;P&gt;it is ANJ, JFJ,YFYU,FFJH,FYFUY&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:04:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479539#M134395</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2020-09-30T05:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between the first and the last row for each page in search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479540#M134396</link>
      <description>&lt;P&gt;Then you should use exact field names:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats first(ANJ) as first_ ANJ, last(ANJ) as last_ ANJ,  first(JFJ) as first_ JFJ, last(JFJ) as last_ JFJ, .....
| foreach ANJ, JFJ, YFYU,......
     [ eval diff_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = last_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; - first_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;] 
| table Date, ANJ, JFJ,YFYU,FFJH,FYFUY, diff_*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Apr 2020 07:04:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479540#M134396</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-04-23T07:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between the first and the last row for each page in search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479541#M134397</link>
      <description>&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 18:41:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-the-first-and-the-last/m-p/479541#M134397</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2020-04-23T18:41:27Z</dc:date>
    </item>
  </channel>
</rss>

