<?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 sum values in a table with a condition that compares columns? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-values-in-a-table-with-a-condition-that-compares/m-p/222769#M65515</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've got a table like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ts1 | ts2 | count  | id
1461347440 | 1461347448 | 5 | 1234
1461347459 | 1461347452 | 10 |  1234
1461347455 | 1461347459 | 10 |  7899
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to sum "count" if  &lt;CODE&gt;ts1&amp;lt;=ts2&lt;/CODE&gt;, for each id. My approach looks like this, but it seems to fail because of the field comparison&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eventstats sum(eval(if(ts1&amp;lt;ts2, count, null()))) AS sum BY Id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you help me to get the wanted calculation?&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;BR /&gt;
Heinz&lt;/P&gt;</description>
    <pubDate>Tue, 26 Apr 2016 16:01:20 GMT</pubDate>
    <dc:creator>HeinzWaescher</dc:creator>
    <dc:date>2016-04-26T16:01:20Z</dc:date>
    <item>
      <title>How to sum values in a table with a condition that compares columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-values-in-a-table-with-a-condition-that-compares/m-p/222769#M65515</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've got a table like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ts1 | ts2 | count  | id
1461347440 | 1461347448 | 5 | 1234
1461347459 | 1461347452 | 10 |  1234
1461347455 | 1461347459 | 10 |  7899
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to sum "count" if  &lt;CODE&gt;ts1&amp;lt;=ts2&lt;/CODE&gt;, for each id. My approach looks like this, but it seems to fail because of the field comparison&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eventstats sum(eval(if(ts1&amp;lt;ts2, count, null()))) AS sum BY Id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you help me to get the wanted calculation?&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;BR /&gt;
Heinz&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 16:01:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-values-in-a-table-with-a-condition-that-compares/m-p/222769#M65515</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2016-04-26T16:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum values in a table with a condition that compares columns?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-values-in-a-table-with-a-condition-that-compares/m-p/222770#M65516</link>
      <description>&lt;P&gt;Whenever you try to add &lt;CODE&gt;null&lt;/CODE&gt;, you will trash your field so use &lt;CODE&gt;0&lt;/CODE&gt; instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats sum(eval(if(ts1&amp;lt;ts2, count, 0))) AS sum BY Id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Apr 2016 16:13:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-values-in-a-table-with-a-condition-that-compares/m-p/222770#M65516</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-26T16:13:28Z</dc:date>
    </item>
  </channel>
</rss>

