<?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 vs SearchMatch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243213#M189016</link>
    <description>&lt;P&gt;A true Boolean value holds the result of an assertion (a yes/no test).  It's actual content is known only to the "operating system".  Booleans cannot be used with an [in]equality operator because we don't know what to compare them to.&lt;BR /&gt;
Many programming languages, like C, don't use true Booleans.  They assign numeric values to "true" and "false" which allows for constructs such as 'if foo == 0' (a statement which is true if foo is false).&lt;BR /&gt;
Before we get too far off-track, the original eval command is converting a Boolean expression ('detail.journey'="Interstitial") into a numeric expression (1 or 0) for some later use.  Splunk restricts how Booleans can be used in some commands, but converting the Boolean to an integer removes those restrictions.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2016 18:06:51 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2016-03-16T18:06:51Z</dc:date>
    <item>
      <title>If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243206#M189009</link>
      <description>&lt;P&gt;Hi, I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I'm starting to get to grips with the 'If' statements and understand the basics around these. But I'm using an existing query which contains the line as shown below.&lt;/P&gt;

&lt;P&gt;I would understand this if it didn't have the &lt;STRONG&gt;1&lt;/STRONG&gt; at the end of the statement, but I just wondered whether someone could explain what the &lt;STRONG&gt;1&lt;/STRONG&gt; actually does. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Interstitpage=if('detail.journey'="Interstitial",1, 0 ) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In addition could someone tell me please would it more efficient to use the "searchmatch" I've read about, and if, could someone possibly explain I may incorporate it into this example.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 14:00:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243206#M189009</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-03-16T14:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243207#M189010</link>
      <description>&lt;P&gt;The eval statement is creating a pseudo-boolean variable and setting its value.  If the detail.journey field has the value "Interstitial" then Interstitpage is set to 1 to represent 'true'; otherwise it is set to 0 to represent 'false'.&lt;BR /&gt;
I've not used the searchmatch function in part because it is poorly documented.  Chatter about it on Answers, however, indicate including a field name in searchmatch can be problematic.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 14:24:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243207#M189010</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-03-16T14:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243208#M189011</link>
      <description>&lt;P&gt;Hi @richgalloway, thank you for taking the time to reply to my post,  so in essence it's looking to see if a value exists?&lt;/P&gt;

&lt;P&gt;So if I've undertsood it correctly in another example I have here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval NewUserOptedOut=if(('detail.digital'="false") AND ('detail.journey'="Interstitial"),1, 0 )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Am I correct in saying that if &lt;STRONG&gt;both&lt;/STRONG&gt; "detail.digitial="false &lt;STRONG&gt;AND&lt;/STRONG&gt; "detail.journey"=Intersitial" then set the result to "True", if not set to "False"?&lt;/P&gt;

&lt;P&gt;Many thanks and kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 14:58:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243208#M189011</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-03-16T14:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243209#M189012</link>
      <description>&lt;P&gt;Yes, you are correct, except that NewUserOptedOut will not be a true Boolean variable.  That is, a statement like &lt;CODE&gt;if (NewUserOptedOut, foo, bar)&lt;/CODE&gt; won't work.  It would have to be &lt;CODE&gt;if (NewUserOptedOut==1, foo, bar)&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 15:06:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243209#M189012</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-03-16T15:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243210#M189013</link>
      <description>&lt;P&gt;Hi, so it's clearly a little different to where there is only one field i.e. one variable?&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 15:12:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243210#M189013</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-03-16T15:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243211#M189014</link>
      <description>&lt;P&gt;I don't understand your question, Chris.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 15:29:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243211#M189014</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-03-16T15:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243212#M189015</link>
      <description>&lt;P&gt;Hi, my apologies. I was just a little confused by your reply where you highlighted that "NewUserOptedOut" would not be a true boolean. I guess I put 2 and 2 together and came up with 5.&lt;/P&gt;

&lt;P&gt;Is there any chance you could elaborate on your answer please.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 15:37:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243212#M189015</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-03-16T15:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243213#M189016</link>
      <description>&lt;P&gt;A true Boolean value holds the result of an assertion (a yes/no test).  It's actual content is known only to the "operating system".  Booleans cannot be used with an [in]equality operator because we don't know what to compare them to.&lt;BR /&gt;
Many programming languages, like C, don't use true Booleans.  They assign numeric values to "true" and "false" which allows for constructs such as 'if foo == 0' (a statement which is true if foo is false).&lt;BR /&gt;
Before we get too far off-track, the original eval command is converting a Boolean expression ('detail.journey'="Interstitial") into a numeric expression (1 or 0) for some later use.  Splunk restricts how Booleans can be used in some commands, but converting the Boolean to an integer removes those restrictions.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 18:06:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243213#M189016</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-03-16T18:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement vs SearchMatch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243214#M189017</link>
      <description>&lt;P&gt;Hi, thank you for coming back to me with this. This explanation helps a great deal, so thank you for taking the time to put it together.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 06:13:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-Statement-vs-SearchMatch/m-p/243214#M189017</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-03-17T06:13:58Z</dc:date>
    </item>
  </channel>
</rss>

