<?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: timechart with calculated field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/timechart-with-calculated-field/m-p/31716#M6598</link>
    <description>&lt;P&gt;Yes, I forgot the 'search' inside the subsearch, but I'm still facing the same problem. My issue here is that it's not recognizing the field from the outer search, which I'm using to calculate a value in the subsearch. To make the query clearer:&lt;/P&gt;

&lt;P&gt;"searchA" | timechart span=1d count AS SEARCH_A_COUNT | fields + SEARCH_A_COUNT | appendcols [search "totalSearch" | timechart span=1d count as TOTAL_SEARCH_COUNT | eval SEARCH_B_COUNT=TOTAL_SEARCH_COUNT-SEARCH_A_COUNT]&lt;/P&gt;

&lt;P&gt;The SEARCH_B_COUNT is derived from the difference between total count and searchA count, but it's not recognizing the SEARCH_A_COUNT&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 13:19:21 GMT</pubDate>
    <dc:creator>dbautist</dc:creator>
    <dc:date>2020-09-28T13:19:21Z</dc:date>
    <item>
      <title>timechart with calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/timechart-with-calculated-field/m-p/31714#M6596</link>
      <description>&lt;P&gt;I have two separate searches and I want to display the results in 1 timechart with a calculated field.&lt;/P&gt;

&lt;P&gt;"searchA" | timechart span=1d count AS SEARCH_A&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;             SEARCH_A     
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2/12/2013        5&lt;BR /&gt;&lt;BR /&gt;
2/13/2013        4             &lt;/P&gt;

&lt;P&gt;"totalSearch" | timechart span=1d count as TOTAL_SEARCH&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;             TOTAL_SEARCH
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2/12/2013        8&lt;BR /&gt;
2/13/2013        11&lt;/P&gt;

&lt;P&gt;I'm using appendcols but I can't get SEARCH_B to display. &lt;/P&gt;

&lt;P&gt;"searchA" | timechart span=1d count AS SEARCH_A | fields + SEARCH_A | appendcols ["totalSearch" | timechart span=1d count as TOTAL_SEARCH | eval SEARCH_B=TOTAL_SEARCH-SEARCH_A]&lt;/P&gt;

&lt;P&gt;The combined result should be something like:&lt;BR /&gt;
                 SEARCH_A      SEARCH_B      TOTAL_SEARCH&lt;BR /&gt;
2/12/2013        5             3             8&lt;BR /&gt;
2/13/2013        4             7             11&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/timechart-with-calculated-field/m-p/31714#M6596</guid>
      <dc:creator>dbautist</dc:creator>
      <dc:date>2020-09-28T13:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: timechart with calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/timechart-with-calculated-field/m-p/31715#M6597</link>
      <description>&lt;P&gt;Is it possible that you forgot to put the &lt;CODE&gt;search&lt;/CODE&gt; keyword in your subsearch?&lt;/P&gt;

&lt;P&gt;Or, try this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"searchA" 
| eval series="Search A" 
| append [ search "totalSearch" | eval series="Search B" ]
| timechart span=1d count by series
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that the second search is limited to 50,000 events by default. If that is not enough, you could do it this way instead - not as clean, but workable:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"searchA" 
| bucket _time span=1d
| stats count by _time
| eval series="Search A" 
| append [ search "totalSearch" 
    | bucket _time span=1d
    | stats count by _time
    | eval series="Search B" ]
| timechart span=1d sum(count) as Count by series
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Feb 2013 08:40:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/timechart-with-calculated-field/m-p/31715#M6597</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-02-14T08:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: timechart with calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/timechart-with-calculated-field/m-p/31716#M6598</link>
      <description>&lt;P&gt;Yes, I forgot the 'search' inside the subsearch, but I'm still facing the same problem. My issue here is that it's not recognizing the field from the outer search, which I'm using to calculate a value in the subsearch. To make the query clearer:&lt;/P&gt;

&lt;P&gt;"searchA" | timechart span=1d count AS SEARCH_A_COUNT | fields + SEARCH_A_COUNT | appendcols [search "totalSearch" | timechart span=1d count as TOTAL_SEARCH_COUNT | eval SEARCH_B_COUNT=TOTAL_SEARCH_COUNT-SEARCH_A_COUNT]&lt;/P&gt;

&lt;P&gt;The SEARCH_B_COUNT is derived from the difference between total count and searchA count, but it's not recognizing the SEARCH_A_COUNT&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:19:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/timechart-with-calculated-field/m-p/31716#M6598</guid>
      <dc:creator>dbautist</dc:creator>
      <dc:date>2020-09-28T13:19:21Z</dc:date>
    </item>
  </channel>
</rss>

