<?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: How do you create an if statement without the else? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-an-if-statement-without-the-else/m-p/439584#M168314</link>
    <description>&lt;P&gt;@zikpefu, If the length of &lt;CODE&gt;field_name&amp;gt;15&lt;/CODE&gt; then do you want to truncate to first 15 characters or make it blank?&lt;/P&gt;

&lt;P&gt;If you want to get only up to first 15 characters you can just use &lt;CODE&gt;substr()&lt;/CODE&gt; evaluation function.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourCurrentSearch&amp;gt;
| eval field_name=substr(field_name,1,15) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want if/else condition you can try something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourCurrentSearch&amp;gt;
| eval field_name=if(len(field_name)&amp;gt;15,substr(field_name,1,15),field_name)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search for you to try out&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval field_name="38927498327321425,287489364"
| makemv field_name delim=","
| mvexpand field_name
| eval result=if(len(field_name)&amp;gt;15,substr(field_name,1,15),field_name)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jul 2018 17:28:37 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-07-16T17:28:37Z</dc:date>
    <item>
      <title>How do you create an if statement without the else?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-an-if-statement-without-the-else/m-p/439582#M168312</link>
      <description>&lt;P&gt;I am producing a table that will monitor what various users are searching for and I am trying to limit the amount of characters the result is to 15 letters (using the eval statement).&lt;/P&gt;

&lt;P&gt;I am trying to use this syntax:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval field_name= if(len(field_name) &amp;gt; 15," ", ???)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help would be appreciated&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 15:22:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-an-if-statement-without-the-else/m-p/439582#M168312</guid>
      <dc:creator>zikpefu</dc:creator>
      <dc:date>2018-07-16T15:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create an if statement without the else?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-an-if-statement-without-the-else/m-p/439583#M168313</link>
      <description>&lt;P&gt;This works?&lt;/P&gt;

&lt;PRE&gt;
|eval field_name= if(len(field_name) &amp;gt; 15," ", field_name)
&lt;/PRE&gt;

&lt;P&gt;You just retain what's there in the field if the length is not greater than 15.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:14:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-an-if-statement-without-the-else/m-p/439583#M168313</guid>
      <dc:creator>pradeepkumarg</dc:creator>
      <dc:date>2018-07-16T17:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create an if statement without the else?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-an-if-statement-without-the-else/m-p/439584#M168314</link>
      <description>&lt;P&gt;@zikpefu, If the length of &lt;CODE&gt;field_name&amp;gt;15&lt;/CODE&gt; then do you want to truncate to first 15 characters or make it blank?&lt;/P&gt;

&lt;P&gt;If you want to get only up to first 15 characters you can just use &lt;CODE&gt;substr()&lt;/CODE&gt; evaluation function.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourCurrentSearch&amp;gt;
| eval field_name=substr(field_name,1,15) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want if/else condition you can try something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourCurrentSearch&amp;gt;
| eval field_name=if(len(field_name)&amp;gt;15,substr(field_name,1,15),field_name)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search for you to try out&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval field_name="38927498327321425,287489364"
| makemv field_name delim=","
| mvexpand field_name
| eval result=if(len(field_name)&amp;gt;15,substr(field_name,1,15),field_name)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:28:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-create-an-if-statement-without-the-else/m-p/439584#M168314</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-07-16T17:28:37Z</dc:date>
    </item>
  </channel>
</rss>

