<?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: Splunk coalesce in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-coalesce/m-p/672513#M230347</link>
    <description>&lt;P&gt;It looks like err_field1contains an empty string.&amp;nbsp; If it was null then err_final would be set to err_field2 or err_field3.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Dec 2023 13:48:58 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-12-21T13:48:58Z</dc:date>
    <item>
      <title>Splunk coalesce</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-coalesce/m-p/672506#M230346</link>
      <description>&lt;P&gt;index="********"&lt;BR /&gt;message_type =ERROR correlation_id="*"&lt;BR /&gt;| eval err_field1 = spath(_raw,"response_details.body")&lt;BR /&gt;| eval err_field2 = spath(_raw,"response_details")&lt;BR /&gt;| eval err_field3 = spath(_raw,"error")&lt;BR /&gt;| eval err_field4 = spath(_raw,"message")&lt;BR /&gt;| eval err_final=coalesce(err_field1,err_field2,err_field3,err_field4)&lt;BR /&gt;| table err_field1 err_field2 err_field3 err_field4 err_final&lt;BR /&gt;&lt;BR /&gt;i have the fields populating for err_field3 and err_field4.. but its not populating in the err_final.&lt;BR /&gt;&lt;BR /&gt;Attached the screenshot for reference&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="splunk.jpg" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28626iDD92BF701F4B9FB6/image-size/large?v=v2&amp;amp;px=999" role="button" title="splunk.jpg" alt="splunk.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 11:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-coalesce/m-p/672506#M230346</guid>
      <dc:creator>yuvaraj_m91</dc:creator>
      <dc:date>2023-12-21T11:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk coalesce</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-coalesce/m-p/672513#M230347</link>
      <description>&lt;P&gt;It looks like err_field1contains an empty string.&amp;nbsp; If it was null then err_final would be set to err_field2 or err_field3.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 13:48:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-coalesce/m-p/672513#M230347</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-12-21T13:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk coalesce</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-coalesce/m-p/672523#M230348</link>
      <description>&lt;P&gt;In these kinds of situations in Splunk I generally do something like this to replace empty strings with actual null values.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    | foreach err_field*
        [
            | eval
                &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(
                    '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'=="" OR match('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "^\s*$"),
                        null(),
                        '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'
                    )
            ]
    | eval
        err_final=coalesce(err_field1, err_field2, err_field3, err_field4)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1703172241334.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28630i080E0CFA725F857A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1703172241334.png" alt="dtburrows3_0-1703172241334.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can see the coalesce works as expected after replacing nullifying the empty strings.&lt;BR /&gt;&lt;BR /&gt;Note: this is also replacing any values in the err_field* fields that is only whitespace in addition to empty strings.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 15:25:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-coalesce/m-p/672523#M230348</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-21T15:25:44Z</dc:date>
    </item>
  </channel>
</rss>

