<?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 can I filter my results to compare values in two fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-filter-my-results-to-compare-values-in-two-fields/m-p/201821#M58498</link>
    <description>&lt;P&gt;I have 2 fields called &lt;STRONG&gt;sc_bytes&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;cs_bytes&lt;/STRONG&gt; in my  results. How can I then filter my results to give me events when the value for &lt;STRONG&gt;cs_bytes&lt;/STRONG&gt; is &lt;EM&gt;greater&lt;/EM&gt; than the value for &lt;STRONG&gt;sc_bytes&lt;/STRONG&gt;? Much thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2016 16:18:20 GMT</pubDate>
    <dc:creator>cbr654</dc:creator>
    <dc:date>2016-11-01T16:18:20Z</dc:date>
    <item>
      <title>How can I filter my results to compare values in two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-filter-my-results-to-compare-values-in-two-fields/m-p/201821#M58498</link>
      <description>&lt;P&gt;I have 2 fields called &lt;STRONG&gt;sc_bytes&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;cs_bytes&lt;/STRONG&gt; in my  results. How can I then filter my results to give me events when the value for &lt;STRONG&gt;cs_bytes&lt;/STRONG&gt; is &lt;EM&gt;greater&lt;/EM&gt; than the value for &lt;STRONG&gt;sc_bytes&lt;/STRONG&gt;? Much thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 16:18:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-filter-my-results-to-compare-values-in-two-fields/m-p/201821#M58498</guid>
      <dc:creator>cbr654</dc:creator>
      <dc:date>2016-11-01T16:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I filter my results to compare values in two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-filter-my-results-to-compare-values-in-two-fields/m-p/201822#M58499</link>
      <description>&lt;P&gt;You need the &lt;CODE&gt;where&lt;/CODE&gt; command.  This is one of the big differences between using &lt;CODE&gt;search vs&lt;/CODE&gt;where` for subsequently filtering results.  &lt;/P&gt;

&lt;P&gt;Just add this to your search: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where cs_bytes &amp;gt; sc_bytes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In &lt;CODE&gt;search&lt;/CODE&gt; the right hand side of any operator (ie =, &amp;gt;, &amp;lt;) is always assumed to be a literal value (whether or not it's in quotes) but in &lt;CODE&gt;where&lt;/CODE&gt;  unquoted strings on the right hand side are interpreted as the values of that named field. &lt;/P&gt;

&lt;P&gt;The other huge difference of course, is that in &lt;CODE&gt;where&lt;/CODE&gt; you can use any eval functions (ie any of the long list of functions you would more typically see in the &lt;CODE&gt;eval&lt;/CODE&gt; command.)&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;So to take a simple example, you could filter to only the rows where &lt;CODE&gt;cs_bytes&lt;/CODE&gt; is greater than BOTH &lt;CODE&gt;sc_bytes&lt;/CODE&gt; and &lt;CODE&gt;some_other_bytes&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where cs_bytes &amp;gt; max(sc_bytes,some_other_bytes)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 16:24:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-filter-my-results-to-compare-values-in-two-fields/m-p/201822#M58499</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-11-01T16:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I filter my results to compare values in two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-filter-my-results-to-compare-values-in-two-fields/m-p/201823#M58500</link>
      <description>&lt;P&gt;How about this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search cs_bytes&amp;gt;sc_bytes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;e.g.  &lt;CODE&gt;index=foo sourcetype=bar cs_bytes&amp;gt;sc_bytes&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 16:26:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-filter-my-results-to-compare-values-in-two-fields/m-p/201823#M58500</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-01T16:26:32Z</dc:date>
    </item>
  </channel>
</rss>

