<?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: compare two field values for equality in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71778#M17934</link>
    <description>&lt;P&gt;I think I have it figured out - it's a weird one!  Field names are supposed to contain letters, numerals or the underscore, and must start with a letter. &lt;CODE&gt;name-combo&lt;/CODE&gt; violates this rule, but Splunk doesn't complain! The reason why it doesn't work is that in the if statement, Splunk interprets your test as `name - combo = name" - this will never match...&lt;/P&gt;

&lt;P&gt;So change &lt;CODE&gt;name-combo&lt;/CODE&gt; to &lt;CODE&gt;name_combo&lt;/CODE&gt; and it should work.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Sep 2012 22:37:29 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-09-26T22:37:29Z</dc:date>
    <item>
      <title>compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71773#M17929</link>
      <description>&lt;P&gt;I have the output of a firewall config, i want to make sure that our naming standard is consistent with the actual function of the network object.&lt;/P&gt;

&lt;P&gt;I have a table of the name of the object and the subnet and mask.  I want to compare the name and name-combo fields to see if they are the same, and show only those that are not the same.&lt;/P&gt;

&lt;P&gt;example row&lt;BR /&gt;
    cluster          name                   name-combo          subnet          bits    match&lt;BR /&gt;
1   FW1-2            NET69.90.64.0-20   NET69.90.64.0-20    69.90.64.0  20  No Match&lt;BR /&gt;
2   FW1-2            NET69.90.63.0-8    NET69.90.63.0-20    69.90.64.0  20  No Match&lt;/P&gt;

&lt;P&gt;here is my search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`abc_firewall_rules` eventtype=subnet [search index="abc_rules" eventtype=subnet | dedup cluster | fields + source] 
| dedup name,cluster | eval name-combo="NET".subnet."-".bits 
| eval match=if(name-combo=name,"Match","No Match")
|  table cluster,name,name-combo,subnet,bits,match
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;row 1 should show match and row 2 should show no match..&lt;/P&gt;

&lt;P&gt;have tried using | where NOT name=name-combo&lt;BR /&gt;
have tried using | where name!=name-combo&lt;/P&gt;

&lt;P&gt;all show ro results found but in my sample data there are rows that do not match and should show up..&lt;/P&gt;

&lt;P&gt;any ideas ?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 16:25:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71773#M17929</guid>
      <dc:creator>EricPartington</dc:creator>
      <dc:date>2012-09-26T16:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71774#M17930</link>
      <description>&lt;P&gt;I usually do some checks on my fields when this happens using eval to makes sure that i'm comparing what I expect.  This should be comparing string to string but make the types are ok "eval test = if( isstr(name)", "String", "Not String" } table test)".  Everything looks good as far as i can tell.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 18:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71774#M17930</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2012-09-26T18:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71775#M17931</link>
      <description>&lt;P&gt;If your search is working properly, you should have output, regardless of whether things match or not.  Does this search return any results? What does the search job inspector say?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`abc_firewall_rules` eventtype=subnet [search index="abc_rules" eventtype=subnet | dedup cluster | fields + source] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am guessing that this is a problem with your search, not your logic.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 18:45:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71775#M17931</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-09-26T18:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71776#M17932</link>
      <description>&lt;P&gt;well getting somewhere now..&lt;/P&gt;

&lt;P&gt;appears that my field name-combo is not a string (thanks for your test command).&lt;/P&gt;

&lt;P&gt;so i tried to convert the field to string with&lt;BR /&gt;
eval name-combo=tostring(name-combo)&lt;BR /&gt;
however not able to get a "string" output from that&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 18:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71776#M17932</guid>
      <dc:creator>EricPartington</dc:creator>
      <dc:date>2012-09-26T18:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71777#M17933</link>
      <description>&lt;P&gt;the search is fine, i get results from that search, the problem appears to be the concat string isnt coming out as a string to compare with&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 18:48:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71777#M17933</guid>
      <dc:creator>EricPartington</dc:creator>
      <dc:date>2012-09-26T18:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71778#M17934</link>
      <description>&lt;P&gt;I think I have it figured out - it's a weird one!  Field names are supposed to contain letters, numerals or the underscore, and must start with a letter. &lt;CODE&gt;name-combo&lt;/CODE&gt; violates this rule, but Splunk doesn't complain! The reason why it doesn't work is that in the if statement, Splunk interprets your test as `name - combo = name" - this will never match...&lt;/P&gt;

&lt;P&gt;So change &lt;CODE&gt;name-combo&lt;/CODE&gt; to &lt;CODE&gt;name_combo&lt;/CODE&gt; and it should work.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 22:37:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71778#M17934</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-09-26T22:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71779#M17935</link>
      <description>&lt;P&gt;i have a similar problem. I apply a filter after stats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;stats dc(field1) as someCount dc(someThing) as otherCount by group | search NOT someCount=otherCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above search returns all values, regardless of whether they match or not, so assuming its checking where someCount matches a literal of "otherCount". This works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval countDiff=someCount-otherCount | search NOT countDiff=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2013 08:27:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71779#M17935</guid>
      <dc:creator>brettcave</dc:creator>
      <dc:date>2013-01-28T08:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71780#M17936</link>
      <description>&lt;P&gt;Actually Brett, your problem is different.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| search NOT someCount=otherCount&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;is interpreted as&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| search NOT someCount="otherCount"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;search always searches for name=value, whether you use the quotes around the value or not. You could make the first search work by using &lt;CODE&gt;where&lt;/CODE&gt; instead:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | stats dc(field1) as someCount dc(someThing) as otherCount by group &lt;BR /&gt;
| where NOT someCount=otherCount&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2013 20:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/71780#M17936</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-02-08T20:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/543565#M153969</link>
      <description>&lt;P&gt;what if 1 field&amp;nbsp; with string "A" is the substring&amp;nbsp; of flied "B"?&lt;BR /&gt;&lt;STRONG&gt;|where B=*A* ,&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;how can we find out that?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 17:01:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/543565#M153969</guid>
      <dc:creator>payal4296</dc:creator>
      <dc:date>2021-03-12T17:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: compare two field values for equality</title>
      <link>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/543651#M153995</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/129849"&gt;@payal4296&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Please try below; checking if field A is a substring of field B...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval A="%".A."%"
| where B like A&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Mar 2021 15:27:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/compare-two-field-values-for-equality/m-p/543651#M153995</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-03-13T15:27:27Z</dc:date>
    </item>
  </channel>
</rss>

