<?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: Finding max of a count up to each hour of the day in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Finding-max-of-a-count-up-to-each-hour-of-the-day/m-p/294573#M88899</link>
    <description>&lt;P&gt;I think you want &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/Streamstats"&gt;streamstats&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ...  | streamstats max(Visitor_Count) as Max_So_Far
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;just be sure to sort the results appropriately first if needed...&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jul 2017 00:57:19 GMT</pubDate>
    <dc:creator>maciep</dc:creator>
    <dc:date>2017-07-04T00:57:19Z</dc:date>
    <item>
      <title>Finding max of a count up to each hour of the day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-max-of-a-count-up-to-each-hour-of-the-day/m-p/294572#M88898</link>
      <description>&lt;P&gt;I am wrestling with a query around getting a max value of a count per hour up to each. I will explain with an example...&lt;/P&gt;

&lt;P&gt;Hour 1 - 400 visitors&lt;BR /&gt;
Hour 2 - 200 visitors&lt;BR /&gt;
Hour 3 - 250 visitors&lt;BR /&gt;
Hour 4 - 100 visitors&lt;BR /&gt;
Hour 5 - 700 visitors&lt;BR /&gt;
Hour 6 - 900 visitors&lt;/P&gt;

&lt;P&gt;I would like to calculate the max for each hour UP TO that hour. So for Hour 1, max would be 400. For Hour 2, the max will also be 400 since that is the max up to hour 2 (between 400 and 200). The max would be 400 for Hours 3 and 4 as well. Hour 5 would have a max of 700 visitors. Hour 6 would have a max of 900 visitors.&lt;/P&gt;

&lt;P&gt;The structure of data I'm working with is...&lt;BR /&gt;
Hour       Visitor_Count&lt;BR /&gt;
1               400&lt;BR /&gt;
2               200&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;I would like the max per hour up to each hour to be column 3.&lt;/P&gt;

&lt;P&gt;The one thing I've managed to do is calculate the max manually for each hour&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats sum(eval(if(hr&amp;lt;=7,visitor_count,null()))) as max_for_hr_7
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works, but creates a column for each hour, and replicates the values for each column down all of the rows, so not ideal...&lt;BR /&gt;
Hour           Visitor_Count             max_for_hr_1               max_for_hr_2              max_for_hr_3 ....&lt;/P&gt;

&lt;P&gt;Any thoughts on how I could achieve adding one additional column with the max of visitor count up to each hour?&lt;/P&gt;

&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:45:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-max-of-a-count-up-to-each-hour-of-the-day/m-p/294572#M88898</guid>
      <dc:creator>bjmclean</dc:creator>
      <dc:date>2020-09-29T14:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding max of a count up to each hour of the day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-max-of-a-count-up-to-each-hour-of-the-day/m-p/294573#M88899</link>
      <description>&lt;P&gt;I think you want &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/Streamstats"&gt;streamstats&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ...  | streamstats max(Visitor_Count) as Max_So_Far
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;just be sure to sort the results appropriately first if needed...&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 00:57:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-max-of-a-count-up-to-each-hour-of-the-day/m-p/294573#M88899</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2017-07-04T00:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Finding max of a count up to each hour of the day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-max-of-a-count-up-to-each-hour-of-the-day/m-p/294574#M88900</link>
      <description>&lt;P&gt;Thank you @maciep! That worked perfectly!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 13:05:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-max-of-a-count-up-to-each-hour-of-the-day/m-p/294574#M88900</guid>
      <dc:creator>bjmclean</dc:creator>
      <dc:date>2017-07-05T13:05:07Z</dc:date>
    </item>
  </channel>
</rss>

