<?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: Issue with if()? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33085#M7007</link>
    <description>&lt;P&gt;The rule regarding strings vs numbers in quotes is true in most &lt;CODE&gt;where&lt;/CODE&gt; and &lt;CODE&gt;eval&lt;/CODE&gt; statements, but not in &lt;CODE&gt;search&lt;/CODE&gt; statements.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jan 2011 00:29:58 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2011-01-27T00:29:58Z</dc:date>
    <item>
      <title>Issue with if()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33081#M7003</link>
      <description>&lt;P&gt;Hey everyone. I am working to try and take a call record, subtract the time a call was placed from the time it was answered. This much works. After that I am trying to take the resulting number, and if its less than 30 eval it into another column. Here's the code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sandbox" sourcetype="AS-CDR" 
|where Called_Number="2155551060" OR Calling_Number="2155551060" OR Called_Number="12155551060" OR Calling_Number="12155551060" OR Called_Number="+12155551060" OR Calling_Number="+12155551060"
|eval TimeToAnswer=strptime(Answer_Time, "%Y%m%d%H%M%S.%q") - strptime(Start_Time, "%Y%m%d%H%M%S.%q")
|eval TimeToAnswerTest=if((TimeToAnswer&amp;lt;"30"),1,0)
|table TimeToAnswer TimeToAnswerTest
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For some of the calls a result of 1 is seen when it should be. However for others, it isn't. Here are some example values that I'm getting back:&lt;/P&gt;

&lt;P&gt;TimeToAnswer~TimeToAnswerTest
67.151000~0 (correct)
8.930000~0 (incorrect)
2.568000~1 (correct)
5.115000~0 (incorrect)
3.341000~1 (correct)&lt;/P&gt;

&lt;P&gt;Any advice on what could be causing this would be extremely helpful. The numbers are being generated correctly, so I'm not sure why the if operator isn't always working correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2011 00:02:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33081#M7003</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2011-01-27T00:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with if()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33082#M7004</link>
      <description>&lt;P&gt;I believe it is the "s around the 30.&lt;/P&gt;

&lt;P&gt;Try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sandbox" sourcetype="AS-CDR" 
|where Called_Number="2155551060" OR Calling_Number="2155551060" OR Called_Number="12155551060" OR Calling_Number="12155551060" OR Called_Number="+12155551060" OR Calling_Number="+12155551060"
|eval TimeToAnswer=strptime(Answer_Time, "%Y%m%d%H%M%S.%q") - strptime(Start_Time, "%Y%m%d%H%M%S.%q")
|eval TimeToAnswerTest=if((TimeToAnswer&amp;lt;30),1,0)
|table TimeToAnswer TimeToAnswerTest
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jan 2011 00:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33082#M7004</guid>
      <dc:creator>vaijpc</dc:creator>
      <dc:date>2011-01-27T00:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with if()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33083#M7005</link>
      <description>&lt;P&gt;That worked perfectly. When you use quotes, does splunk process the contents of the quotes as a string as opposed to an integer/float?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2011 00:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33083#M7005</guid>
      <dc:creator>msarro</dc:creator>
      <dc:date>2011-01-27T00:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with if()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33084#M7006</link>
      <description>&lt;P&gt;I'm guessing that's the case, it certainly sounds sensible. I'm afraid I'm a newbie too though. FYI, those brackets around the test are also unnecessary.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2011 00:23:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33084#M7006</guid>
      <dc:creator>vaijpc</dc:creator>
      <dc:date>2011-01-27T00:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with if()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33085#M7007</link>
      <description>&lt;P&gt;The rule regarding strings vs numbers in quotes is true in most &lt;CODE&gt;where&lt;/CODE&gt; and &lt;CODE&gt;eval&lt;/CODE&gt; statements, but not in &lt;CODE&gt;search&lt;/CODE&gt; statements.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2011 00:29:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-with-if/m-p/33085#M7007</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-01-27T00:29:58Z</dc:date>
    </item>
  </channel>
</rss>

