<?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 dynamically put formulas in my table column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-put-formulas-in-my-table-column/m-p/246160#M73399</link>
    <description>&lt;P&gt;You need to calculate &lt;STRONG&gt;delta&lt;/STRONG&gt; for current bucket and previous one (provided your results are sorted by time).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Logic: attached value for current row minus diffCount for current row will give you the attached value of previous row.&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   Your base search | eval X=0.01 | delta attached as diffCount | eval forecast = (attached-diffCount)*X + (attached-diffCount) | table _time, attached, forecast 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I dont think you need a forecast value for the first row. However, if you need you can pipe the following code after delta command to set diffCount to 0 for the first row where it is null.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval diffCount=if(isnull(diffCount),0,diffCount) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Assuming your base search calculates value of factor X, I have hard-coded above as 0.01. Hopefully your base search will calculate the same.&lt;/P&gt;</description>
    <pubDate>Sat, 03 Dec 2016 10:12:02 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2016-12-03T10:12:02Z</dc:date>
    <item>
      <title>How to dynamically put formulas in my table column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-put-formulas-in-my-table-column/m-p/246158#M73397</link>
      <description>&lt;P&gt;This is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timechart  span=mon max(c117492014) as "attached" |
eval lic=180000 |
eval forecast = "" | 
eval tcheck=round(strptime("2016-12-01","%Y-%m-%d"),0) | 
eval forecast=if(_time==tcheck,164444,forecast) | 
fields - tcheck
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this is the result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time   attached          forecast  lic
1   2016-09 133757              180000
2   2016-10 147797              180000
3   2016-11 163994              180000
4   2016-12             164444   180000
5   2017-01                      180000
6   2017-02                      180000
7   2017-03                      180000
8   2017-04                      180000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It is probably a step in the right direction but it is currently very static. I would like to make it more dynamic for future use. &lt;/P&gt;

&lt;P&gt;This is what I would like to achive in the forecast column I would like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;in row 4 (163994*X)+163994
in row 5 (&amp;lt;value in row 4 of forecast column&amp;gt;*X)+&amp;lt;value in row 4 of forecast column&amp;gt;
in row 6 (&amp;lt;value in row 5 of forecast column&amp;gt;*X)+&amp;lt;value in row 5 of forecast column&amp;gt;
in row 7 (&amp;lt;value in row 6 of forecast column&amp;gt;*X)+&amp;lt;value in row 6 of forecast column&amp;gt;
in row 8 (&amp;lt;value in row 7 of forecast column&amp;gt;*X)+&amp;lt;value in row 7 of forecast column&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Nov 2016 03:08:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-put-formulas-in-my-table-column/m-p/246158#M73397</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-11-24T03:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically put formulas in my table column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-put-formulas-in-my-table-column/m-p/246159#M73398</link>
      <description>&lt;P&gt;this doesn't really answer your question, but have you thought about using the &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Predict"&gt;predict&lt;/A&gt; function?  Maybe something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart  span=mon max(c117492014) as "attached"
| predict attached future_timespan=4
| eval license="180000"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Dec 2016 01:44:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-put-formulas-in-my-table-column/m-p/246159#M73398</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-12-03T01:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically put formulas in my table column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-put-formulas-in-my-table-column/m-p/246160#M73399</link>
      <description>&lt;P&gt;You need to calculate &lt;STRONG&gt;delta&lt;/STRONG&gt; for current bucket and previous one (provided your results are sorted by time).&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Logic: attached value for current row minus diffCount for current row will give you the attached value of previous row.&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   Your base search | eval X=0.01 | delta attached as diffCount | eval forecast = (attached-diffCount)*X + (attached-diffCount) | table _time, attached, forecast 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I dont think you need a forecast value for the first row. However, if you need you can pipe the following code after delta command to set diffCount to 0 for the first row where it is null.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval diffCount=if(isnull(diffCount),0,diffCount) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Assuming your base search calculates value of factor X, I have hard-coded above as 0.01. Hopefully your base search will calculate the same.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Dec 2016 10:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-put-formulas-in-my-table-column/m-p/246160#M73399</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-12-03T10:12:02Z</dc:date>
    </item>
  </channel>
</rss>

