<?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 deduct two sums in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227826#M188360</link>
    <description>&lt;P&gt;either do as @somesoni2 suggests or provide some sample events and your complete search. Makes it easier to help &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 20:32:38 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2016-01-18T20:32:38Z</dc:date>
    <item>
      <title>How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227819#M188353</link>
      <description>&lt;P&gt;I am trying to sum 2 Fields of a search and then deduct the one from the other:&lt;/P&gt;

&lt;P&gt;my idea is not working:&lt;/P&gt;

&lt;P&gt;| stats sum( eval (stats sum(Field1)) - (stats( sum(Field2)) ) AS difference12&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jan 2016 20:42:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227819#M188353</guid>
      <dc:creator>highriser666</dc:creator>
      <dc:date>2016-01-17T20:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227820#M188354</link>
      <description>&lt;P&gt;Hi highriser666,&lt;/P&gt;

&lt;P&gt;take this run everywhere command as example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=_internal | stats sum(kb) AS KB sum(kbps) AS KBPS | eval diff=KB-KBPS
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You frist have to &lt;CODE&gt;sum()&lt;/CODE&gt; your fields (here it is &lt;CODE&gt;kb&lt;/CODE&gt; and &lt;CODE&gt;kbps&lt;/CODE&gt;) and then evaluate the difference.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 02:40:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227820#M188354</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-01-18T02:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227821#M188355</link>
      <description>&lt;P&gt;How about:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats sum(Field1) as Sum1, sum(Field2) as Sum2 | eval difference12 = Sum1-Sum2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2016 02:41:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227821#M188355</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2016-01-18T02:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227822#M188356</link>
      <description>&lt;P&gt;Thank you, &lt;/P&gt;

&lt;P&gt;I tried  is already before getting mad with the other term.&lt;/P&gt;

&lt;P&gt;When I do as you suggest the stats it gives me always only the sums for field1 and field2. &lt;/P&gt;

&lt;P&gt;"Difference12" is not shown as the expected single value in the stats-tab of the results even though it should be the &lt;BR /&gt;
singular result of the term.&lt;/P&gt;

&lt;P&gt;Stats always only shows field1 and field2. &lt;/P&gt;

&lt;P&gt;Currently Field2 is all time NULL could that cause an issue?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 08:26:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227822#M188356</guid>
      <dc:creator>highriser666</dc:creator>
      <dc:date>2016-01-18T08:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227823#M188357</link>
      <description>&lt;P&gt;or you can try like :&lt;/P&gt;

&lt;P&gt;...| timechart  eval(sum(Field1)- sum(Field2)) as difference12&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 13:23:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227823#M188357</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2016-01-18T13:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227824#M188358</link>
      <description>&lt;P&gt;Yes, if the value of a field is always NULL, the stats will return NULL for the Field2 and subsequent diff will also be NULL. &lt;/P&gt;

&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search  | stats sum(Field1) AS Field1 sum(Field2) AS Field2  | fillnull value=0 Field2 | eval Difference12 =Field1 -Field1 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2016 15:30:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227824#M188358</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-01-18T15:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227825#M188359</link>
      <description>&lt;P&gt;this will not work, because &lt;CODE&gt;sum()&lt;/CODE&gt; is not an eval function, but the other way around it will work (run everywhere example):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=_internal | timechart sum(eval(kb-kbps)) AS diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I doubt this will be the correct result, because it will not calculate the total difference. On the other hand the use case is not 100% clear so maybe it could work &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227825#M188359</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-01-18T20:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to deduct two sums</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227826#M188360</link>
      <description>&lt;P&gt;either do as @somesoni2 suggests or provide some sample events and your complete search. Makes it easier to help &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 20:32:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-deduct-two-sums/m-p/227826#M188360</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-01-18T20:32:38Z</dc:date>
    </item>
  </channel>
</rss>

