<?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 count the delta of the first and the last event in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507022#M2356</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/189417"&gt;@spisiakmi&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Assuming that the counter always increases and does not reset , try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"your search"|stats max(Value) as high,min(Value) as low by ID
|eval consumption=high-low&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jul 2020 09:58:53 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2020-07-02T09:58:53Z</dc:date>
    <item>
      <title>How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507006#M2355</link>
      <description>&lt;P&gt;Hi, can you help me to solve this problem, please?&lt;/P&gt;&lt;P&gt;I have index=index1&lt;/P&gt;&lt;P&gt;In a specified time range, e.g. 3 hours, I have these events. Time is a regular time point, where the electric power has been measured. ID is the name of the electrical counter, which counts the electrical measurements. Value is the measured electrical power [kW].&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Time&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;ID&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 06:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 06:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;2000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 06:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter3&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;3000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 07:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;2000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 07:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;3000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 07:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter3&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;4000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 08:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;3000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&lt;SPAN&gt;02.07.2020 08:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;counter2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;4000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;02.07.2020 08:00:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;counter3&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;How can I count the consumption of each counter in this time range?&lt;/P&gt;&lt;P&gt;I need this output&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;ID&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;consumption&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;counter1&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;2000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;counter2&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;2000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;counter3&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;2000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 09:11:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507006#M2355</guid>
      <dc:creator>spisiakmi</dc:creator>
      <dc:date>2020-07-02T09:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507022#M2356</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/189417"&gt;@spisiakmi&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Assuming that the counter always increases and does not reset , try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"your search"|stats max(Value) as high,min(Value) as low by ID
|eval consumption=high-low&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 09:58:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507022#M2356</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-07-02T09:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507046#M2359</link>
      <description>&lt;P&gt;@enjith_nair&amp;nbsp;you have absolutely right. It was so easy and I made it already so many times. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 11:17:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507046#M2359</guid>
      <dc:creator>spisiakmi</dc:creator>
      <dc:date>2020-07-02T11:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507047#M2360</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/189417"&gt;@spisiakmi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;can we say the the max value for each ID is the result you want?&lt;/P&gt;&lt;P&gt;if yes, try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1
| stats max(value) AS value BY ID&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 11:23:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507047#M2360</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-07-02T11:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507049#M2362</link>
      <description>&lt;P&gt;Hi&lt;SPAN class="UserName lia-user-name lia-user-rank-Legend lia-component-message-view-widget-author-username"&gt;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352" target="_self"&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp;@gcusello&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;no, you need to do max-min. The counter always increase.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 11:30:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507049#M2362</guid>
      <dc:creator>spisiakmi</dc:creator>
      <dc:date>2020-07-02T11:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507051#M2363</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="Time	ID	Value
02.07.2020 06:00:00	counter1	1000
02.07.2020 06:00:00	counter2	2000
02.07.2020 06:00:00	counter3	3000
02.07.2020 07:00:00	counter1	2000
02.07.2020 07:00:00	counter2	3000
02.07.2020 07:00:00	counter3	4000
02.07.2020 08:00:00	counter1	3000
02.07.2020 08:00:00	counter2	4000
02.07.2020 08:00:00	counter3	5000"
| multikv forceheader=1
| stats range(Value) by ID&lt;/LI-CODE&gt;&lt;P&gt;try &lt;STRONG&gt;| stats range()&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 11:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507051#M2363</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-02T11:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507052#M2364</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;&lt;/P&gt;&lt;P&gt;ou yeah. very very elegant.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 11:39:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507052#M2364</guid>
      <dc:creator>spisiakmi</dc:creator>
      <dc:date>2020-07-02T11:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to count the delta of the first and the last event</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507053#M2365</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/189417"&gt;@spisiakmi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1
| stats max(Value) as max min(Value) as min by ID
| eval delta=max-min&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 11:46:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-count-the-delta-of-the-first-and-the-last-event/m-p/507053#M2365</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-07-02T11:46:59Z</dc:date>
    </item>
  </channel>
</rss>

