<?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: If statement will not evaluate as true in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-If-statement-evaluate-as-true/m-p/626605#M217793</link>
    <description>&lt;P&gt;Renaming the field worked! Thank you&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2023 14:53:03 GMT</pubDate>
    <dc:creator>anjuliwyles</dc:creator>
    <dc:date>2023-01-10T14:53:03Z</dc:date>
    <item>
      <title>Why won't If statement evaluate as true?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-If-statement-evaluate-as-true/m-p/626602#M217790</link>
      <description>&lt;P&gt;When I place event.code into an if statement, it will not evaluate as true&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently I have this code:&lt;/P&gt;
&lt;P&gt;index = windows-security event.code IN (4624)&lt;BR /&gt;| eval Success=if(event.code = "4624", 1, 0)&lt;BR /&gt;| stats count by Success&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Success always evaluates to 0. I have tried using&lt;/P&gt;
&lt;P&gt;match(event.code, "4624")&lt;/P&gt;
&lt;P&gt;match(event.code, '4624')&lt;/P&gt;
&lt;P&gt;match(event.code, ".+")&lt;/P&gt;
&lt;P&gt;like(event.code, "4624")&lt;/P&gt;
&lt;P&gt;like(event.code, '4624')&lt;/P&gt;
&lt;P&gt;I even tried event.code = event.code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Always 0.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 17:23:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-If-statement-evaluate-as-true/m-p/626602#M217790</guid>
      <dc:creator>anjuliwyles</dc:creator>
      <dc:date>2023-01-11T17:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: If statement will not evaluate as true</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-If-statement-evaluate-as-true/m-p/626604#M217792</link>
      <description>&lt;P&gt;Since event.code probably is an integer have you tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Success=if(event.code = 4624, 1, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's possible Splunk is struggling with the field name.&amp;nbsp; Try renaming it before the conditional.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename event.* as *
| eval Success = if(code=4624, 1, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 14:44:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-If-statement-evaluate-as-true/m-p/626604#M217792</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-01-10T14:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: If statement will not evaluate as true</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-If-statement-evaluate-as-true/m-p/626605#M217793</link>
      <description>&lt;P&gt;Renaming the field worked! Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 14:53:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-If-statement-evaluate-as-true/m-p/626605#M217793</guid>
      <dc:creator>anjuliwyles</dc:creator>
      <dc:date>2023-01-10T14:53:03Z</dc:date>
    </item>
  </channel>
</rss>

