<?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 Eval type error on subseach in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-type-error-on-subseach/m-p/54769#M13367</link>
    <description>&lt;P&gt;Hi all, I'm having a few issues with using a subsearch within an eval statement. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="capacityanalysisindex01" 
| timechart span=1d count by eventtype 
| stats avg(*) 
| eval ratio=(eventtype / ([ search index="capacityanalysisindex01" 
                                      tag::eventtype="EVENTS_PURCHASE_ALL" 
                              | stats count ]))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Running this, I receive the error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'eval' command: Typechecking failed. '/' only takes numbers.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd have thought that the output of the subsearch would have been a number? If I replace it with an integer, eg, 2, the query works fine (though obviously the results are incorrect), and running the subsearch on its own produces the appropriate output; I just can't link them together. &lt;/P&gt;

&lt;P&gt;Essentially what I'm TRYING to do is to:
1. Count up the different event types over a day.
2. Compute the average of each eventtype across each of the days.
3. Divide the averages by the total number of purchase events.&lt;/P&gt;

&lt;P&gt;Is there a simple fix to this, or is there a better way of producing the desired results?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2011 09:10:21 GMT</pubDate>
    <dc:creator>jarrodrobins</dc:creator>
    <dc:date>2011-03-07T09:10:21Z</dc:date>
    <item>
      <title>Eval type error on subseach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-type-error-on-subseach/m-p/54769#M13367</link>
      <description>&lt;P&gt;Hi all, I'm having a few issues with using a subsearch within an eval statement. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="capacityanalysisindex01" 
| timechart span=1d count by eventtype 
| stats avg(*) 
| eval ratio=(eventtype / ([ search index="capacityanalysisindex01" 
                                      tag::eventtype="EVENTS_PURCHASE_ALL" 
                              | stats count ]))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Running this, I receive the error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'eval' command: Typechecking failed. '/' only takes numbers.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd have thought that the output of the subsearch would have been a number? If I replace it with an integer, eg, 2, the query works fine (though obviously the results are incorrect), and running the subsearch on its own produces the appropriate output; I just can't link them together. &lt;/P&gt;

&lt;P&gt;Essentially what I'm TRYING to do is to:
1. Count up the different event types over a day.
2. Compute the average of each eventtype across each of the days.
3. Divide the averages by the total number of purchase events.&lt;/P&gt;

&lt;P&gt;Is there a simple fix to this, or is there a better way of producing the desired results?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2011 09:10:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-type-error-on-subseach/m-p/54769#M13367</guid>
      <dc:creator>jarrodrobins</dc:creator>
      <dc:date>2011-03-07T09:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Eval type error on subseach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-type-error-on-subseach/m-p/54770#M13368</link>
      <description>&lt;P&gt;The output of the subsearch is actually &lt;CODE&gt;count=17&lt;/CODE&gt;,  not just the &lt;CODE&gt;17&lt;/CODE&gt;.  This is because subsearches are made primarily to output searchterms into other searches.  &lt;/P&gt;

&lt;P&gt;You're not out of luck though,  and you dont even have to break out the &lt;CODE&gt;format&lt;/CODE&gt; command.  Subsearches have special behavior where a) if there's only a single field and b) it's called &lt;CODE&gt;query&lt;/CODE&gt; or &lt;CODE&gt;search&lt;/CODE&gt;,  then it will output only the value.   so tack on an &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rename count as search&lt;/CODE&gt;  &lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2011 11:51:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-type-error-on-subseach/m-p/54770#M13368</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-03-07T11:51:52Z</dc:date>
    </item>
  </channel>
</rss>

