<?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: Unable to use eval with stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102054#M26362</link>
    <description>&lt;P&gt;Hi.. do want to sum up all fields. Or is it just one. Since I don't have your data to play with, I used access_combined logs with clientip and status instead of id and uid.&lt;/P&gt;

&lt;P&gt;From what I understand in your query, your first stats command will give you two columns, and then you filter one out with the fields command. Then you just have id left.&lt;/P&gt;

&lt;P&gt;See edit of original answer for more info.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2011 23:30:33 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2011-11-01T23:30:33Z</dc:date>
    <item>
      <title>Unable to use eval with stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102051#M26359</link>
      <description>&lt;P&gt;How do I use eval in below query to add hard coded value, say 1000 to the final count?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex | stats first(id) by uid | fields – uid | stats sum()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex | stats first(id) by uid | fields – uid | stats eval(1000 + sum()) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but the eval does not work with stats…&lt;/P&gt;

&lt;P&gt;Any help is much appreciated!&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2011 22:23:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102051#M26359</guid>
      <dc:creator>freephoneid</dc:creator>
      <dc:date>2011-11-01T22:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to use eval with stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102052#M26360</link>
      <description>&lt;P&gt;Hmm, not really sure about what you're trying to accomplish, but adding a static value is quite simple. Since I don't really understand your goals, I'll illustrate it with adding 1000 to the http-status value in an access_combined log.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=access_combined | eval status=status+1000 | stats values(status) AS new_status by clientip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This results in a table like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;clientip      new_status
----------------------
1.2.3.4       1404
              1200
              1503

1.2.3.5       1200
              1302
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps a little bit at least. Feel free to give more information on what you want to achieve.&lt;/P&gt;

&lt;P&gt;UPDATE: would the following search give the same results as what you have right now, i.e. not adding the 1000?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex | stats first(id) AS temp_id by uid | stats sum(temp_id) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in that case&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex | stats first(id) AS temp_id by uid | stats sum(temp_id) AS temp_id | eval temp_id = temp_id +1000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;should to the trick. &lt;/P&gt;

&lt;P&gt;/Kristian&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2011 22:58:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102052#M26360</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2011-11-01T22:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to use eval with stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102053#M26361</link>
      <description>&lt;P&gt;hi...I want to add hard coded value 1000 to the output of the stats sum()....How can I do this?  If index=myindex | stats first(id) by uid | fields – uid | stats sum() gives 500 as output then I want it to be displayed as 1500 as single value...&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2011 23:07:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102053#M26361</guid>
      <dc:creator>freephoneid</dc:creator>
      <dc:date>2011-11-01T23:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to use eval with stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102054#M26362</link>
      <description>&lt;P&gt;Hi.. do want to sum up all fields. Or is it just one. Since I don't have your data to play with, I used access_combined logs with clientip and status instead of id and uid.&lt;/P&gt;

&lt;P&gt;From what I understand in your query, your first stats command will give you two columns, and then you filter one out with the fields command. Then you just have id left.&lt;/P&gt;

&lt;P&gt;See edit of original answer for more info.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2011 23:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-use-eval-with-stats/m-p/102054#M26362</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2011-11-01T23:30:33Z</dc:date>
    </item>
  </channel>
</rss>

