<?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 Eval can not concatenate fields where there is a null value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61550#M15202</link>
    <description>&lt;P&gt;Given that:&lt;/P&gt;

&lt;P&gt;Field1="foo"&lt;/P&gt;

&lt;P&gt;Field2=""&lt;/P&gt;

&lt;P&gt;(Field2 has a null value)&lt;/P&gt;

&lt;P&gt;and we use eval to concatenate the two&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Field3=Field1.Field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Field3=Field1+Field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then Field3 will contain the null value instead "foo". Instead it seems that with a null value we see it overwrite or ignore the non-null values and the whole thing just becomes a null value.&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2012 20:46:53 GMT</pubDate>
    <dc:creator>Rob</dc:creator>
    <dc:date>2012-01-31T20:46:53Z</dc:date>
    <item>
      <title>Eval can not concatenate fields where there is a null value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61550#M15202</link>
      <description>&lt;P&gt;Given that:&lt;/P&gt;

&lt;P&gt;Field1="foo"&lt;/P&gt;

&lt;P&gt;Field2=""&lt;/P&gt;

&lt;P&gt;(Field2 has a null value)&lt;/P&gt;

&lt;P&gt;and we use eval to concatenate the two&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Field3=Field1.Field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Field3=Field1+Field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then Field3 will contain the null value instead "foo". Instead it seems that with a null value we see it overwrite or ignore the non-null values and the whole thing just becomes a null value.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2012 20:46:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61550#M15202</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2012-01-31T20:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Eval can not concatenate fields where there is a null value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61551#M15203</link>
      <description>&lt;P&gt;The workaround for this is to use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval Field3=if(isnotnull(Field2), Field1.Field2, Field1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This would assume that we know that Field1 will always have a value and sometimes Field2 might only contain a null value by using the &lt;CODE&gt;if()&lt;/CODE&gt; and &lt;CODE&gt;isnotnull()&lt;/CODE&gt; functions of eval to test whether the field has a NULL value. If there is no NULL value then we concatenate the fields, if there is a NULL value, we simply take the first field that has a value as the value we want to keep.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2012 20:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61551#M15203</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2012-01-31T20:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Eval can not concatenate fields where there is a null value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61552#M15204</link>
      <description>&lt;P&gt;Hi Rob, another option is coalesce&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Field3=coalesce(Field1,"").coalesce(Field2,"")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2012 21:25:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61552#M15204</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2012-01-31T21:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Eval can not concatenate fields where there is a null value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61553#M15205</link>
      <description>&lt;P&gt;Thanks for that dwaddle! I like it, its sort of temporarily replacing the null value with an empty value and concatenating for a new field.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2012 21:36:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-can-not-concatenate-fields-where-there-is-a-null-value/m-p/61553#M15205</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2012-01-31T21:36:58Z</dc:date>
    </item>
  </channel>
</rss>

