<?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: Fill null delta for multiple object in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596986#M207806</link>
    <description>&lt;P&gt;Assuming ascending values and events in time order, try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;``` Assuming your search gives events in time order ```
``` fill nulls with -1 (so they can be detected after untable) ```
| fillnull value=-1
``` untable so events can be processed by id ```
| untable _time id valLast
``` split off original null fields ```
| eval null=if(valLast=-1,1,0)
| eval valLast=if(valLast=-1,null(),valLast)
``` filldown using max (assumes valLast doesn't decrease) ```
| streamstats max(valLast) as valLast by id
``` find change in valLast and detect start and end of sequence of nulls ```
| streamstats range(valLast) as diff range(null) as nulls window=2 global=f by id
``` count nulls by id ```
| streamstats sum(null) as nullnumber global=f by id
``` calculate null number at start of sequence ```
| eval start=if(null=1 AND nulls=1,nullnumber,null())
``` calculate null number at end of sequence ```
| eval end=if(null=0 AND nulls=1,nullnumber,null())
``` filldown null number by id ```
| streamstats max(start) as start by id
``` calculate number of events to spread the difference over ```
| eval nullsplusone=end-start+1+1
``` spread the difference across nulls and end of sequence ```
| eval diffspread=diff/nullsplusone
``` reverse events ```
| reverse
``` filldown spread diff by id ```
| streamstats last(diffspread) as lastdiff by id
``` calculate new difference based on whether first non-null after a sequence or originally null ```
| eval newdiff=if(isnotnull(end) OR null=1, lastdiff, diff)
``` reverse to original order ```
| reverse
``` rechart by time and id ```
| xyseries _time id newdiff&lt;/LI-CODE&gt;&lt;P&gt;Comments to hopefully make it clear what's going on&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2022 15:19:49 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-05-09T15:19:49Z</dc:date>
    <item>
      <title>Fill null delta for multiple object</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596921#M207777</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I have a set of data as below. In the column is value of each id according to the time&lt;/P&gt;&lt;TABLE border="0" width="320" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="80" height="20"&gt;_time&lt;/TD&gt;&lt;TD width="80"&gt;id = 12345&lt;/TD&gt;&lt;TD width="80"&gt;id = 12347&lt;/TD&gt;&lt;TD width="80"&gt;id = 12349&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;01-févr&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;02-févr&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;03-févr&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;04-févr&lt;/TD&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;05-févr&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;06-févr&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;07-févr&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;140&lt;/TD&gt;&lt;TD&gt;56&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;08-févr&lt;/TD&gt;&lt;TD&gt;57&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;09-févr&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;155&lt;/TD&gt;&lt;TD&gt;75&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;10-févr&lt;/TD&gt;&lt;TD&gt;70&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I would like to&amp;nbsp; calculate delta then fill the null delta.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;I have this piece of&amp;nbsp; code, until here I can calculate the delta for each id, I am finding the solution for the filling null delta:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;index="index" [|inputlookup test.csv&lt;BR /&gt;| search id=1234**&lt;BR /&gt;|timechart latest(value) as valLast span=1d by id&lt;BR /&gt;|untable _time id valLast&lt;BR /&gt;|streamstats current=false window=1 global=false first(valLast) as p_valLast by id&lt;BR /&gt;| eval delta=valLast-p_valLast&lt;BR /&gt;| xyseries _time id delta&lt;BR /&gt;|streamstats count(eval(if(isnull(delta),0,null()))) as count by id&lt;/P&gt;&lt;P&gt;Result: columns display delta values according to each id in a time&lt;/P&gt;&lt;TABLE border="0" width="320" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="80" height="20"&gt;_time&lt;/TD&gt;&lt;TD width="80"&gt;id = 1&lt;/TD&gt;&lt;TD width="80"&gt;id = 2&lt;/TD&gt;&lt;TD width="80"&gt;id = 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;01-févr&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;02-févr&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;03-févr&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;04-févr&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;05-févr&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;06-févr&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;07-févr&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;56&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;08-févr&lt;/TD&gt;&lt;TD&gt;57&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;09-févr&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;10-févr&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advanced!&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 10:31:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596921#M207777</guid>
      <dc:creator>Julia1231</dc:creator>
      <dc:date>2022-05-09T10:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Fill null delta for multiple object</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596928#M207779</link>
      <description>&lt;P&gt;I am not 100% clear what it is you are trying to achieve but does this help?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ndex="index" [|inputlookup test.csv
| search id=1234**
|timechart latest(value) as valLast span=1d by id
|untable _time id valLast
|streamstats current=false window=1 global=false first(valLast) as p_valLast by id
| eval delta=valLast-p_valLast
| fillnull value=0
| xyseries _time id delta&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 May 2022 11:21:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596928#M207779</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-05-09T11:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Fill null delta for multiple object</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596935#M207781</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for your feedback and sorry it's not clear.&lt;/P&gt;&lt;P&gt;Here is the original data (base on delta)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julia1231_0-1652097151512.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/19517i2265845BA278F64F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julia1231_0-1652097151512.png" alt="Julia1231_0-1652097151512.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And here is what I aim to do:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Julia1231_1-1652097250566.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/19518i9B12127667F444B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Julia1231_1-1652097250566.png" alt="Julia1231_1-1652097250566.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Get the value of 08 feb and divide by the total null bar + 1 (8 feb) and refill to null and 8 feb.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The other id is expected the same way of doing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 12:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596935#M207781</guid>
      <dc:creator>Julia1231</dc:creator>
      <dc:date>2022-05-09T12:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fill null delta for multiple object</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596980#M207802</link>
      <description>&lt;P&gt;Is valLast always the same or higher than the previous value for each id?&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 14:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596980#M207802</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-05-09T14:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Fill null delta for multiple object</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596986#M207806</link>
      <description>&lt;P&gt;Assuming ascending values and events in time order, try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;``` Assuming your search gives events in time order ```
``` fill nulls with -1 (so they can be detected after untable) ```
| fillnull value=-1
``` untable so events can be processed by id ```
| untable _time id valLast
``` split off original null fields ```
| eval null=if(valLast=-1,1,0)
| eval valLast=if(valLast=-1,null(),valLast)
``` filldown using max (assumes valLast doesn't decrease) ```
| streamstats max(valLast) as valLast by id
``` find change in valLast and detect start and end of sequence of nulls ```
| streamstats range(valLast) as diff range(null) as nulls window=2 global=f by id
``` count nulls by id ```
| streamstats sum(null) as nullnumber global=f by id
``` calculate null number at start of sequence ```
| eval start=if(null=1 AND nulls=1,nullnumber,null())
``` calculate null number at end of sequence ```
| eval end=if(null=0 AND nulls=1,nullnumber,null())
``` filldown null number by id ```
| streamstats max(start) as start by id
``` calculate number of events to spread the difference over ```
| eval nullsplusone=end-start+1+1
``` spread the difference across nulls and end of sequence ```
| eval diffspread=diff/nullsplusone
``` reverse events ```
| reverse
``` filldown spread diff by id ```
| streamstats last(diffspread) as lastdiff by id
``` calculate new difference based on whether first non-null after a sequence or originally null ```
| eval newdiff=if(isnotnull(end) OR null=1, lastdiff, diff)
``` reverse to original order ```
| reverse
``` rechart by time and id ```
| xyseries _time id newdiff&lt;/LI-CODE&gt;&lt;P&gt;Comments to hopefully make it clear what's going on&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 15:19:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fill-null-delta-for-multiple-object/m-p/596986#M207806</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-05-09T15:19:49Z</dc:date>
    </item>
  </channel>
</rss>

