<?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: Comparing two fields with &amp;gt; operator in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-with-gt-operator/m-p/16894#M2285</link>
    <description>&lt;P&gt;I think you want to use &lt;CODE&gt;where&lt;/CODE&gt; and not &lt;CODE&gt;search&lt;/CODE&gt;.  The &lt;CODE&gt;where&lt;/CODE&gt; search operation lets you compare variables or even &lt;CODE&gt;eval&lt;/CODE&gt; expressions, but &lt;CODE&gt;search&lt;/CODE&gt; only looks for literal values.  Here's an example.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;This search is looking for a field named "user" that contains the value of "login":&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| search user=login&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;This search is looking for a field named "user" that contains the same value as the field named "login":&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| where user=login&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;So you should be able to take your example search expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval over=time_taken-threshold | search over&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And change it to either:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where (time_taken-threshold)&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where time_taken&amp;gt;threshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Jul 2010 20:43:52 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2010-07-06T20:43:52Z</dc:date>
    <item>
      <title>Comparing two fields with &gt; operator</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-with-gt-operator/m-p/16893#M2284</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am trying to compare two fields with a simple operator but it does not seem to perform as expected.  I am simply trying to return any transaction times that are over the value of the 'threshold' field. This is what I'm trying:&lt;/P&gt;

&lt;P&gt;&lt;I&gt;time_taken&amp;gt;threshold&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;I have found another way around this by using the eval command:&lt;/P&gt;

&lt;P&gt;&lt;I&gt;eval over=time_taken-threshold | search over&amp;gt;0&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;This essentially does the same thing in a very round about way but it less than neat.&lt;/P&gt;

&lt;P&gt;Is there something i'm missing to compare field to another field?  I have scoured documention but can't find any examples of this.&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2010 15:59:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-with-gt-operator/m-p/16893#M2284</guid>
      <dc:creator>srw46</dc:creator>
      <dc:date>2010-07-06T15:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields with &gt; operator</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-with-gt-operator/m-p/16894#M2285</link>
      <description>&lt;P&gt;I think you want to use &lt;CODE&gt;where&lt;/CODE&gt; and not &lt;CODE&gt;search&lt;/CODE&gt;.  The &lt;CODE&gt;where&lt;/CODE&gt; search operation lets you compare variables or even &lt;CODE&gt;eval&lt;/CODE&gt; expressions, but &lt;CODE&gt;search&lt;/CODE&gt; only looks for literal values.  Here's an example.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;This search is looking for a field named "user" that contains the value of "login":&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| search user=login&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;This search is looking for a field named "user" that contains the same value as the field named "login":&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| where user=login&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;So you should be able to take your example search expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval over=time_taken-threshold | search over&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And change it to either:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where (time_taken-threshold)&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where time_taken&amp;gt;threshold
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2010 20:43:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-with-gt-operator/m-p/16894#M2285</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-07-06T20:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two fields with &gt; operator</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-with-gt-operator/m-p/16895#M2286</link>
      <description>&lt;P&gt;Splendid.&lt;/P&gt;

&lt;P&gt;Thank you again Lowell.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2010 14:01:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-fields-with-gt-operator/m-p/16895#M2286</guid>
      <dc:creator>srw46</dc:creator>
      <dc:date>2010-07-07T14:01:13Z</dc:date>
    </item>
  </channel>
</rss>

