<?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 How to calculate the difference between two rows with multiple fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-two-rows-with-multiple/m-p/448061#M168267</link>
    <description>&lt;P&gt;I have a search returns two rows of records (check the result from the following query):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval date="2018-07-16", col1=4, col2=5, col3=6, col4=7
| append [| makeresults 
| eval date="2018-07-17", col1=8, col2=9, col3=16, col4=17]
| fields - _time
| table date col1 col2 col3 col4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to get the difference between the date from all the columns?  Here is the expected result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval date="2018-07-16", col1=4, col2=5, col3=6, col4=7
| append [| makeresults 
| eval date="2018-07-17", col1=8, col2=9, col3=16, col4=17]
| append [| makeresults 
| eval date="diff", col1=4, col2=4, col3=10, col4=10]
| fields - _time
| table date col1 col2 col3 col4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jul 2018 21:09:21 GMT</pubDate>
    <dc:creator>splunkrocks2014</dc:creator>
    <dc:date>2018-07-18T21:09:21Z</dc:date>
    <item>
      <title>How to calculate the difference between two rows with multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-two-rows-with-multiple/m-p/448061#M168267</link>
      <description>&lt;P&gt;I have a search returns two rows of records (check the result from the following query):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval date="2018-07-16", col1=4, col2=5, col3=6, col4=7
| append [| makeresults 
| eval date="2018-07-17", col1=8, col2=9, col3=16, col4=17]
| fields - _time
| table date col1 col2 col3 col4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to get the difference between the date from all the columns?  Here is the expected result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval date="2018-07-16", col1=4, col2=5, col3=6, col4=7
| append [| makeresults 
| eval date="2018-07-17", col1=8, col2=9, col3=16, col4=17]
| append [| makeresults 
| eval date="diff", col1=4, col2=4, col3=10, col4=10]
| fields - _time
| table date col1 col2 col3 col4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:09:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-two-rows-with-multiple/m-p/448061#M168267</guid>
      <dc:creator>splunkrocks2014</dc:creator>
      <dc:date>2018-07-18T21:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference between two rows with multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-two-rows-with-multiple/m-p/448062#M168268</link>
      <description>&lt;P&gt;@splunkrocks2014 ,&lt;/P&gt;

&lt;P&gt;Try this,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval date="2018-07-16", col1=4, col2=5, col3=6, col4=7
 | append [| makeresults 
 | eval date="2018-07-17", col1=8, col2=9, col3=16, col4=17]
 | fields - _time
 | table date col1 col2 col3 col4
 | transpose|rename "row 1" as row1,"row 2" as row2
 | eval diff=if(column!="date",(row2-row1),null())
 | transpose header_field=column|fields - column|fillnull value=diff date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jul 2018 04:29:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-difference-between-two-rows-with-multiple/m-p/448062#M168268</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-07-19T04:29:37Z</dc:date>
    </item>
  </channel>
</rss>

