<?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: Can't evaluate expression in query over multiple files in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137042#M37535</link>
    <description>&lt;P&gt;Thanks! Adding the stats clause worked. I appreciate your help.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2014 21:11:42 GMT</pubDate>
    <dc:creator>rjahrling</dc:creator>
    <dc:date>2014-02-04T21:11:42Z</dc:date>
    <item>
      <title>Can't evaluate expression in query over multiple files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137039#M37532</link>
      <description>&lt;P&gt;Here's my query in Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=kpidata source="*avail*" | eval Time = _time | eval days_in_month = round((relative_time(_time,"@mon+1mon")-relative_time(_time,"@mon"))/86400) | convert rmunit("Achieved Average") as unsched_num | convert rmunit("Operational Average") as total_num | eval unsched_downtime = days_in_month * (100 - unsched_num) | eval total_downtime = days_in_month * (100 - total_num) | timechart max(total_downtime) max(unsched_downtime)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...and it works great. I am pulling Operational Average and Achieved Average out of the files as text ("98.7%"), converting them to numbers (98.7), and using them in calculations without difficulty.  The calculation for &lt;CODE&gt;days_in_month&lt;/CODE&gt; is returning correct values. The results for the query appear correct, and the graphs correspond to existing graphs.&lt;/P&gt;

&lt;P&gt;But.&lt;/P&gt;

&lt;P&gt;I want to be able to calculate a value called &lt;CODE&gt;sched_downtime&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval sched_downtime = total_downtime - unsched_downtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I add that to the query (before the timechart, of course), no values are returned. I'm not sure I understand what's going on. I can say &lt;CODE&gt;sched_downtime = total_downtime&lt;/CODE&gt; and data appears; I can say &lt;CODE&gt;sched_downtime = total_downtime + 3&lt;/CODE&gt; and data appears. I can do the same, manipulating &lt;CODE&gt;unsched_downtime&lt;/CODE&gt; alone. But if I try to use the two downtime stats together...nothing.&lt;/P&gt;

&lt;P&gt;I tried skipping the intermediate &lt;CODE&gt;*_downtime&lt;/CODE&gt; calculations entirely, but that didn't make a difference either. It looks like if I try to use both the unscheduled and total numbers in a single &lt;CODE&gt;eval&lt;/CODE&gt;, there will be no results--but no errors, either, at least not that I can see.&lt;/P&gt;

&lt;P&gt;"Operational Average" and "Achieved Average" are fields in separate files. Does that matter? What have I done wrong? How can I get the value for &lt;CODE&gt;sched_downtime&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 20:08:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137039#M37532</guid>
      <dc:creator>rjahrling</dc:creator>
      <dc:date>2014-02-04T20:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can't evaluate expression in query over multiple files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137040#M37533</link>
      <description>&lt;P&gt;Since "Operational Average" and "Achieved Average" are fields in separate files, they both don't appear in the same event/row when you're calculating your &lt;CODE&gt;total_downtime&lt;/CODE&gt; and "&lt;CODE&gt;unsched_downtime&lt;/CODE&gt;". If in your current query, your remove the timechart part and added below, your will get data like this.&lt;/P&gt;

&lt;P&gt;Query to replace timechart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| table _time, total_downtime, unsched_downtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time   total_downtime      unsched_downtime 
............................................
timestamp1   total_downtime1  NULL/Blank
timestamp1    NULL/Blank      unsched_downtime1
....
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Because of one of them will NULL for every event, the "&lt;CODE&gt;|eval sched_downtime = total_downtime - unsched_downtime&lt;/CODE&gt;" returns nothing.&lt;/P&gt;

&lt;P&gt;One workaround here, assuming you want to do timechart daily (your can change it per your need), try following.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=kpidata source="*avail*" | eval Time = _time | eval days_in_month = round((relative_time(_time,"@mon+1mon")-relative_time(_time,"@mon"))/86400) | convert rmunit("Achieved Average") as unsched_num | convert rmunit("Operational Average") as total_num | eval unsched_downtime = days_in_month * (100 - unsched_num) | eval total_downtime = days_in_month * (100 - total_num) | bucket span=1d _time | stats max(total_downtime) as total_downtime, max(unsched_downtime) as unsched_downtime by _time |eval sched_downtime = total_downtime - unsched_downtime | timechart max(total_downtime) max(unsched_downtime) max(sched_downtime)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2014 20:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137040#M37533</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-02-04T20:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can't evaluate expression in query over multiple files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137041#M37534</link>
      <description>&lt;P&gt;oops, one should not watch TV while editing answers.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 20:39:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137041#M37534</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-02-04T20:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can't evaluate expression in query over multiple files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137042#M37535</link>
      <description>&lt;P&gt;Thanks! Adding the stats clause worked. I appreciate your help.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 21:11:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-evaluate-expression-in-query-over-multiple-files/m-p/137042#M37535</guid>
      <dc:creator>rjahrling</dc:creator>
      <dc:date>2014-02-04T21:11:42Z</dc:date>
    </item>
  </channel>
</rss>

