<?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: time chart only computing the first part of the calculation in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580525#M202246</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your input. I tried you suggestion but I get the same error as when I daisy-chain them.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jan 2022 21:50:05 GMT</pubDate>
    <dc:creator>splunk3341</dc:creator>
    <dc:date>2022-01-10T21:50:05Z</dc:date>
    <item>
      <title>time chart only computing the first part of the calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580504#M202240</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am working with the timechart command on my following query and I am running into some problems.&lt;BR /&gt;&lt;BR /&gt;I am trying to compute:&amp;nbsp;&lt;BR /&gt;timechart span=15m sum(ofAField) as sumOfField, avg(sumOfField) as avgOfField by task&lt;BR /&gt;&lt;BR /&gt;My problem with this one is that when I run it. I get the correct output for the first task but the out for the rest of the task are wrong. I am assuming that for the rest of the tasks only the sum portion of the time chart query is being calculated and not the avg. For background context there are about 11 different task this time chart is being grouped by.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 18:27:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580504#M202240</guid>
      <dc:creator>splunk3341</dc:creator>
      <dc:date>2022-01-10T18:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: time chart only computing the first part of the calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580507#M202242</link>
      <description>&lt;P&gt;I'm 99% sure you can't daisy-chain expressions like that - at least not successfully.&amp;nbsp; Try computing the sum and average in different commands, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| bin span=15m _time
| stats sum(ofAField) as sumOfField by _time,task
| timechart span=15m avg(sumOfField) as avgOfField by task&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 10 Jan 2022 18:40:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580507#M202242</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-01-10T18:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: time chart only computing the first part of the calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580525#M202246</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your input. I tried you suggestion but I get the same error as when I daisy-chain them.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 21:50:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580525#M202246</guid>
      <dc:creator>splunk3341</dc:creator>
      <dc:date>2022-01-10T21:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: time chart only computing the first part of the calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580530#M202249</link>
      <description>&lt;P&gt;Please tell us more about the error.&amp;nbsp; What results are expected and what do you get?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 01:04:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580530#M202249</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-01-11T01:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: time chart only computing the first part of the calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580546#M202255</link>
      <description>&lt;P&gt;If I understand you correctly, you are getting the sum of "ofAField" in a 15 minute period. In that case, what exactly should the average show for that 15 minute period - I am assuming you are looking for a flat line of the average across your time range.&lt;/P&gt;&lt;P&gt;In that case, you would do this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=1000
| streamstats c
| eval _time=_time-(c*10)
| eval task=mvindex(split("taskA,taskB,taskC,taskD", ","), random() % 4)
| eval ofAfield=random() % 100
| timechart span=15m sum(ofAfield) as sumofAfield by task
| eventstats avg(*) as avg_*&lt;/LI-CODE&gt;&lt;P&gt;The last two lines are what you want, i.e. you first take the sum of 'ofAfield" and then use eventstats to compute the average&lt;/P&gt;&lt;P&gt;Then using a bar chart with an overlay of the average fields you can produce this sort of output - is this what you wanted?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bowesmana_0-1641880742594.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17505iD6E9BE776E1EFA0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bowesmana_0-1641880742594.png" alt="bowesmana_0-1641880742594.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 05:59:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/time-chart-only-computing-the-first-part-of-the-calculation/m-p/580546#M202255</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-01-11T05:59:15Z</dc:date>
    </item>
  </channel>
</rss>

