<?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 copy figures across empty time buckets? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238156#M188684</link>
    <description>&lt;P&gt;Sorry about that. I guess I would need to understand your data better. The problem is that first half of your data (table 1, before 2015-09-16), everything is cumulative already and everything after that is not (this is based on your expected table 2). Is this correct?? If it's correct can I assume, anything after the null/0 values, I need to accumulate and before that is already accumulated?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Sep 2015 16:50:07 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2015-09-23T16:50:07Z</dc:date>
    <item>
      <title>How to copy figures across empty time buckets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238153#M188681</link>
      <description>&lt;P&gt;I'm generating a timechart that is supposed to display a daily figure which is an accumulation of total logged in hours by users.&lt;/P&gt;

&lt;P&gt;I have two problems, firstly some users may login a couple of days and never again which has the result of their total hours not getting added to subsequent days. &lt;BR /&gt;
Secondly there may be some days (like the 16th &amp;amp; 17th below) that have had no login events whatsoever which has the result of an empty bucket where I'd like to see the total from the previous day instead.&lt;/P&gt;

&lt;P&gt;The table of results I'm getting is something like this:&lt;BR /&gt;
_time OpSys_1&lt;BR /&gt;
2015-09-12 0&lt;BR /&gt;
2015-09-13 24&lt;BR /&gt;
2015-09-14 48&lt;BR /&gt;
2015-09-15 72&lt;BR /&gt;
2015-09-16 &lt;BR /&gt;
2015-09-17 &lt;BR /&gt;
2015-09-18 1&lt;BR /&gt;
2015-09-19 82&lt;BR /&gt;
2015-09-20 152&lt;/P&gt;

&lt;P&gt;These are the results I'd like:&lt;BR /&gt;
_time   OpSys_1&lt;BR /&gt;
2015-09-12 0&lt;BR /&gt;
2015-09-13 24&lt;BR /&gt;
2015-09-14 48&lt;BR /&gt;
2015-09-15 72&lt;BR /&gt;
2015-09-16 &lt;STRONG&gt;72&lt;/STRONG&gt;&lt;BR /&gt;
2015-09-17 &lt;STRONG&gt;72&lt;/STRONG&gt;&lt;BR /&gt;
2015-09-18 &lt;STRONG&gt;73&lt;/STRONG&gt; (1 + 72)&lt;BR /&gt;
2015-09-19 &lt;STRONG&gt;155&lt;/STRONG&gt; (82 + 73)&lt;BR /&gt;
2015-09-20 &lt;STRONG&gt;307&lt;/STRONG&gt; (152 + 155)&lt;/P&gt;

&lt;P&gt;Query:&lt;BR /&gt;
index=Agate | &lt;BR /&gt;
streamstats first(LoggedInTotal) as VeryFirstLoggedInTotal last(LoggedInTotal) as VeryLastLoggedInTotal by User OpSys | &lt;BR /&gt;
bucket _time span=1d | &lt;BR /&gt;
fields _time VeryFirstLoggedInTotal VeryLastLoggedInTotal LoggedInTotal User OpSys | &lt;BR /&gt;
stats first(VeryFirstLoggedInTotal) as FirstLoggedInTotal last(LoggedInTotal) as LastLoggedInTotal last(VeryLastLoggedInTotal) as NewVeryLastLoggedInTotal by User OpSys _time | &lt;BR /&gt;
eval LastMinusFirst_LoggedInTotal=if(isnotnull(LastLoggedInTotal),tonumber(mvindex(split(LastLoggedInTotal, ":"),0))-tonumber(mvindex(split(FirstLoggedInTotal, ":"),0)),tonumber(mvindex(split(NewVeryLastLoggedInTotal, ":"),0))-tonumber(mvindex(split(FirstLoggedInTotal, ":"),0))) | &lt;BR /&gt;
streamstats sum(LastMinusFirst_LoggedInTotal) as sum_LoggedInTotal_by_OpSys by _time OpSys | &lt;BR /&gt;
timechart span=1d limit=0 last(sum_LoggedInTotal_by_OpSys) by OpSys&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:21:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238153#M188681</guid>
      <dc:creator>szal</dc:creator>
      <dc:date>2020-09-29T07:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy figures across empty time buckets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238154#M188682</link>
      <description>&lt;P&gt;I think you're almost there, Assuming your current query which gave first output is working just fine, try this (see the last line added)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=Agate |  streamstats first(LoggedInTotal) as VeryFirstLoggedInTotal last(LoggedInTotal) as VeryLastLoggedInTotal by User OpSys |   bucket _time span=1d |  fields _time VeryFirstLoggedInTotal VeryLastLoggedInTotal LoggedInTotal User OpSys | 
    stats first(VeryFirstLoggedInTotal) as FirstLoggedInTotal last(LoggedInTotal) as LastLoggedInTotal last(VeryLastLoggedInTotal) as NewVeryLastLoggedInTotal by User OpSys _time | 
    eval LastMinusFirst_LoggedInTotal=if(isnotnull(LastLoggedInTotal),tonumber(mvindex(split(LastLoggedInTotal, ":"),0))-tonumber(mvindex(split(FirstLoggedInTotal, ":"),0)),tonumber(mvindex(split(NewVeryLastLoggedInTotal, ":"),0))-tonumber(mvindex(split(FirstLoggedInTotal, ":"),0))) | 
    streamstats sum(LastMinusFirst_LoggedInTotal) as sum_LoggedInTotal_by_OpSys by _time OpSys | 
    timechart span=1d limit=0 last(sum_LoggedInTotal_by_OpSys) by OpSys
| streamstats sum(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Sep 2015 15:45:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238154#M188682</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-23T15:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy figures across empty time buckets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238155#M188683</link>
      <description>&lt;P&gt;Thanks for your fast response!... adding the last line&lt;BR /&gt;
| streamstats sum(*) as *&lt;BR /&gt;
to the end of the query does have the desired effect but the totals for each day are now much larger than they should be.&lt;BR /&gt;
I can see that the first empty bucket now has taken the previous bucket total and doubled it - which is wrong.&lt;BR /&gt;
In the above example 2015-09-16 72 is now 2015-09-16 144&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 16:13:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238155#M188683</guid>
      <dc:creator>szal</dc:creator>
      <dc:date>2015-09-23T16:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy figures across empty time buckets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238156#M188684</link>
      <description>&lt;P&gt;Sorry about that. I guess I would need to understand your data better. The problem is that first half of your data (table 1, before 2015-09-16), everything is cumulative already and everything after that is not (this is based on your expected table 2). Is this correct?? If it's correct can I assume, anything after the null/0 values, I need to accumulate and before that is already accumulated?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 16:50:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238156#M188684</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-23T16:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy figures across empty time buckets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238157#M188685</link>
      <description>&lt;P&gt;table 1 above is derived from this data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;User    OpSys   _time   FirstLoggedInTotal  LastLoggedInTotal   NewVeryLastLoggedInTotal    LastMinusFirst_LoggedInTotal
user_2  OpSys_1 2015-09-12  00:02:12    00:02:12    00:02:12    0
user_3  OpSys_1 2015-09-12  00:02:14    00:02:11    00:02:11    0
user_4  OpSys_1 2015-09-12  00:02:17    00:02:04    00:02:04    0
user_2  OpSys_1 2015-09-13  00:02:12    24:02:17    24:02:17    24
user_2  OpSys_1 2015-09-14  00:02:12    48:03:03    48:03:03    48
user_2  OpSys_1 2015-09-15  00:02:12    72:03:34    72:03:34    72
user_1  OpSys_1 2015-09-18  00:02:18    00:02:18    00:02:18    0
user_3  OpSys_1 2015-09-18  00:02:14    01:15:07    01:15:07    1
user_4  OpSys_1 2015-09-18  00:02:17                00:02:04    0
user_5  OpSys_1 2015-09-18  00:02:20    00:02:20    00:02:20    0
user_1  OpSys_1 2015-09-19  00:02:18    38:17:36    38:17:36    38
user_3  OpSys_1 2015-09-19  00:02:14    18:25:58    18:25:58    18
user_4  OpSys_1 2015-09-19  00:02:17    02:12:04    02:12:04    2
user_5  OpSys_1 2015-09-19  00:02:20    24:02:27    24:02:27    24
user_1  OpSys_1 2015-09-20  00:02:18    62:19:15    62:19:15    62
user_3  OpSys_1 2015-09-20  00:02:14    42:26:03    42:26:03    42
user_4  OpSys_1 2015-09-20  00:02:17    00:36:55    00:36:55    0
user_5  OpSys_1 2015-09-20  00:02:20    48:03:01    48:03:01    48
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2015 09:35:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238157#M188685</guid>
      <dc:creator>szal</dc:creator>
      <dc:date>2015-09-24T09:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy figures across empty time buckets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238158#M188686</link>
      <description>&lt;P&gt;Looking at this data closely the results on day 2015-09-19 should be 154 hours and on 2015-09-20 should be 224 hours.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time              user_1   user_2  user_3  user_4  user_5  totals
2015-09-12  0           0           0           0           0           0
2015-09-13  0          24           0           0           0           24
2015-09-14  0          48           0           0           0           48
2015-09-15  0          72           0           0           0           72
2015-09-16  0          72           0           0           0           72
2015-09-17  0          72           0           0           0           72
2015-09-18  0          72           1           0           0           73
2015-09-19  38         72           18          2           24          154
2015-09-20  62         72           42          0           48          224
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BTW - I've also noticed that user_4 on 2015-09-20 has zero hours - clearly it should be at least 2 hours and points to a bug in the data supplied by that user on that day.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 10:52:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238158#M188686</guid>
      <dc:creator>szal</dc:creator>
      <dc:date>2015-09-24T10:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy figures across empty time buckets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238159#M188687</link>
      <description>&lt;P&gt;In order to get this working I needed to change the calculation method used for LastMinusFirst_LoggedInTotal so that it didn't accumulate the total for each user across buckets - this part is done by the suggested answer from somesoni2.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 12:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-figures-across-empty-time-buckets/m-p/238159#M188687</guid>
      <dc:creator>szal</dc:creator>
      <dc:date>2015-09-25T12:35:31Z</dc:date>
    </item>
  </channel>
</rss>

