<?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 Splunk eval not working with generated column in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-eval-not-working-with-generated-column/m-p/284937#M176734</link>
    <description>&lt;P&gt;Need some help on some Splunk Search Syntax.&lt;/P&gt;

&lt;P&gt;| inputlookup defect__kvs &lt;BR /&gt;
| search (week_date="&lt;EM&gt;") (type="&lt;/EM&gt;") (sub_type="&lt;EM&gt;") (model="&lt;/EM&gt;")  (sub_type=&lt;EM&gt;) (model=&lt;/EM&gt;) &lt;BR /&gt;
| eval  total_polulation=700 (this will be a $token$ in a panel)&lt;BR /&gt;
| stats count by failure sw_type &lt;BR /&gt;
| rename count as num_failure&lt;BR /&gt;&lt;BR /&gt;
| eval pct_of_total=(num_failure/total_population) | table failure sw_type num_failure pct_of_total&lt;/P&gt;

&lt;P&gt;pct_of_total does not produce a value.&lt;/P&gt;

&lt;P&gt;I do not want to do appendcols or a subsearch as the Token is to be widely used and it works in other queries as a variable. Total_polulation cannot be derived from the Event Set.&lt;/P&gt;

&lt;P&gt;Basically the totals are derived in the following XML&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 11:01:16 GMT</pubDate>
    <dc:creator>timcolpo</dc:creator>
    <dc:date>2020-09-29T11:01:16Z</dc:date>
    <item>
      <title>Splunk eval not working with generated column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-eval-not-working-with-generated-column/m-p/284937#M176734</link>
      <description>&lt;P&gt;Need some help on some Splunk Search Syntax.&lt;/P&gt;

&lt;P&gt;| inputlookup defect__kvs &lt;BR /&gt;
| search (week_date="&lt;EM&gt;") (type="&lt;/EM&gt;") (sub_type="&lt;EM&gt;") (model="&lt;/EM&gt;")  (sub_type=&lt;EM&gt;) (model=&lt;/EM&gt;) &lt;BR /&gt;
| eval  total_polulation=700 (this will be a $token$ in a panel)&lt;BR /&gt;
| stats count by failure sw_type &lt;BR /&gt;
| rename count as num_failure&lt;BR /&gt;&lt;BR /&gt;
| eval pct_of_total=(num_failure/total_population) | table failure sw_type num_failure pct_of_total&lt;/P&gt;

&lt;P&gt;pct_of_total does not produce a value.&lt;/P&gt;

&lt;P&gt;I do not want to do appendcols or a subsearch as the Token is to be widely used and it works in other queries as a variable. Total_polulation cannot be derived from the Event Set.&lt;/P&gt;

&lt;P&gt;Basically the totals are derived in the following XML&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:01:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-eval-not-working-with-generated-column/m-p/284937#M176734</guid>
      <dc:creator>timcolpo</dc:creator>
      <dc:date>2020-09-29T11:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk eval not working with generated column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-eval-not-working-with-generated-column/m-p/284938#M176735</link>
      <description>&lt;P&gt;is &lt;EM&gt;eval total_polulation&lt;/EM&gt; copied from your actual query? If so, then your problem is the typo in it.&lt;/P&gt;

&lt;P&gt;I just tried what you did with some other data/fields, and it works for me.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 12:27:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-eval-not-working-with-generated-column/m-p/284938#M176735</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2016-09-15T12:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk eval not working with generated column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-eval-not-working-with-generated-column/m-p/284939#M176736</link>
      <description>&lt;P&gt;Thank for your response.    Actually this was not a typo as I was editing the search to remove customer information.   I did manage to get it to work but it was strange, for if I place the "|eval a=700"    before the stats statement it does not compute, but after it it does. This was the final query.&lt;/P&gt;

&lt;P&gt;THIS DOES NOT WORK&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup defect__kvs 
| search (week_date="*") (type="*") (sub_type="*") (model="*") (sub_type="*") (model="*") 
| eval total_population=700 | stats count by failure sw_type | rename count as num_failure
| eval pct_of_total=(num_failure/total_population) 
| rename count as num_failure | table failure sw_type num_failure pct_of_total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;THIS DOES WORK&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup defect__kvs 
| search (week_date="*") (type="*") (sub_type="*") (model="*") (sub_type="*") (model="*") 
| stats count by failure sw_type | rename count as num_failure
| eval total_population=700
| eval pct_of_total=(num_failure/total_population) 
| rename count as num_failure | table failure sw_type num_failure pct_of_total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Sep 2016 16:04:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-eval-not-working-with-generated-column/m-p/284939#M176736</guid>
      <dc:creator>timcolpo</dc:creator>
      <dc:date>2016-09-15T16:04:31Z</dc:date>
    </item>
  </channel>
</rss>

