<?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 How to nest an eval in an if statement in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-nest-an-eval-in-an-if-statement/m-p/174228#M49993</link>
    <description>&lt;P&gt;Currently  I can use a write an if statement in the following form:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval adjusted_start=start_sum + 1
| eval counter=if(adjusted_start=2,111,555)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where start_sum is a field with a value of either 1 or 2.&lt;/P&gt;

&lt;P&gt;However, is there a way to simplify these two lines into one line? I thought the following would work (nesting the eval into the if statement), but either my syntax is off or you can't do it this way.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval counter=if(eval(start_sum+1)=2,111,555)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jan 2015 19:34:57 GMT</pubDate>
    <dc:creator>Splunkster45</dc:creator>
    <dc:date>2015-01-06T19:34:57Z</dc:date>
    <item>
      <title>How to nest an eval in an if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-nest-an-eval-in-an-if-statement/m-p/174228#M49993</link>
      <description>&lt;P&gt;Currently  I can use a write an if statement in the following form:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval adjusted_start=start_sum + 1
| eval counter=if(adjusted_start=2,111,555)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where start_sum is a field with a value of either 1 or 2.&lt;/P&gt;

&lt;P&gt;However, is there a way to simplify these two lines into one line? I thought the following would work (nesting the eval into the if statement), but either my syntax is off or you can't do it this way.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval counter=if(eval(start_sum+1)=2,111,555)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2015 19:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-nest-an-eval-in-an-if-statement/m-p/174228#M49993</guid>
      <dc:creator>Splunkster45</dc:creator>
      <dc:date>2015-01-06T19:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to nest an eval in an if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-nest-an-eval-in-an-if-statement/m-p/174229#M49994</link>
      <description>&lt;P&gt;You should be able to do math logic inline:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval counter=if(start_sum+1=2,111,555)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jan 2015 19:41:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-nest-an-eval-in-an-if-statement/m-p/174229#M49994</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-01-06T19:41:51Z</dc:date>
    </item>
  </channel>
</rss>

