<?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: Why Doesn't Coalesce work in an If/Case Statement? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372501#M109563</link>
    <description>&lt;P&gt;What is &lt;CODE&gt;$fieldToMatch$&lt;/CODE&gt; here? a token from some form input?&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2018 15:59:56 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-01-04T15:59:56Z</dc:date>
    <item>
      <title>Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372498#M109560</link>
      <description>&lt;P&gt;I am trying to write a search that if the field= Email then perform a coalese, but if the field isn't Email- just put in the field- below is what I have written. It seems like coalesce doesn't work in if or case statements. I also tried to accomplishing this with isNull and it also failed. &lt;/P&gt;

&lt;P&gt;| eval $fieldToMatch$= if($fieldToMatch$==Email, coalesce(Email,NotifyAddress), $fieldToMatch$)&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;

&lt;P&gt;(essentially i am doing a join on a field and the field could either be email, an ID, etc. but if the field to match on is email- the field NotifyAddress might also contain some emails)&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 15:19:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372498#M109560</guid>
      <dc:creator>katzr</dc:creator>
      <dc:date>2018-01-04T15:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372499#M109561</link>
      <description>&lt;P&gt;I think you might be confused about what &lt;CODE&gt;coalesce&lt;/CODE&gt; does.  It selects the field that is not null.  If both the Email and NotifyAddress fields might contain emails then you probably want to merge them using &lt;CODE&gt;Email.NotifyAddress&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 15:28:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372499#M109561</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-01-04T15:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372500#M109562</link>
      <description>&lt;P&gt;No I want to use the functionality of coalesce- so if Email is null- then pull in the value from Notify Address. I don't care about Notify Address if Email has a value. Do you know why this isn't working with if/case?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 15:31:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372500#M109562</guid>
      <dc:creator>katzr</dc:creator>
      <dc:date>2018-01-04T15:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372501#M109563</link>
      <description>&lt;P&gt;What is &lt;CODE&gt;$fieldToMatch$&lt;/CODE&gt; here? a token from some form input?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 15:59:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372501#M109563</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-04T15:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372502#M109564</link>
      <description>&lt;P&gt;yes it is a token that could either be the field Email, ID,Name. So if the field to match on is Email- I need to check for any additional emails to match on that could be in the field NotifyAddress. &lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 16:02:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372502#M109564</guid>
      <dc:creator>katzr</dc:creator>
      <dc:date>2018-01-04T16:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372503#M109565</link>
      <description>&lt;P&gt;why not try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval $fieldToMatch$= case($fieldToMatch$==Email AND isnotnull(Email), Email, $fieldToMatch$==Email AND isnull(Email),NotifyAddress, 1=1,$fieldToMatch$)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jan 2018 16:13:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372503#M109565</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-01-04T16:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372504#M109566</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval "$fieldToMatch$"= if("$fieldToMatch$"=="Email", coalesce(Email,NotifyAddress), '$fieldToMatch$')
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jan 2018 16:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372504#M109566</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-04T16:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372505#M109567</link>
      <description>&lt;P&gt;yes this worked thank you! But can you explain to me what the difference between " and ' is and when to use them?&lt;/P&gt;

&lt;P&gt;Because the goal of my search is to match two data sources on a field (Email for example). The one data source is where I was using this functionality above with Email and Notify address, but the other data source- the field to match on may also be named Email so whoever wrote the search referred to that field as "Email". &lt;/P&gt;

&lt;P&gt;Essentially I need to understand why you use " vs. ' vs. just the field name to make sure this doesn't mess up the rest of my search. Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 16:27:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372505#M109567</guid>
      <dc:creator>katzr</dc:creator>
      <dc:date>2018-01-04T16:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372506#M109568</link>
      <description>&lt;P&gt;If the field names contains special characters, you would enclose them in single quotes in eval/where expressions (e.g. &lt;CODE&gt;..| where &amp;lt;&amp;lt;expression&amp;gt;&amp;gt;&lt;/CODE&gt; or &lt;CODE&gt;..|eval fieldname=&amp;lt;&amp;lt;expression&amp;gt;&amp;gt;&lt;/CODE&gt;). For eval, you can use double quotes on the left side of &lt;CODE&gt;=&lt;/CODE&gt; sign (first one after field name), and must use single quotes on right side of it.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 16:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372506#M109568</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-04T16:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372507#M109569</link>
      <description>&lt;P&gt;okay that makes sense- if I am pulling from two different sources who have fields with the same name- how do I distinguish them? &lt;/P&gt;

&lt;P&gt;Cause the Email used in the above function should all be from one source, but the other source used also has the field Email in it. &lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2018 17:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372507#M109569</guid>
      <dc:creator>katzr</dc:creator>
      <dc:date>2018-01-04T17:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why Doesn't Coalesce work in an If/Case Statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372508#M109570</link>
      <description>&lt;P&gt;There is no way to differentiate just based on field name as fieldnames can be same between different sources. If your expression/logic needs to be different for different sources (though applied on same field name), then  you'd need to include source identifier field (field/fields that can uniquely identify source) into your expressions/logic. e.g. For same original problem, with different expression for sourceA and sourceB (assuming field &lt;CODE&gt;source&lt;/CODE&gt; is uniq identifier), so set the value of field Email differently, you can do like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval "$fieldToMatch$"= case("$fieldToMatch$"=="Email" AND source="sourceA", coalesce(Email,NotifyAddress), "$fieldToMatch$"=="Email" AND source="sourceB", coalesce(Email,Receipiers), , 1=1, '$fieldToMatch$')
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jan 2018 19:23:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-Doesn-t-Coalesce-work-in-an-If-Case-Statement/m-p/372508#M109570</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-04T19:23:57Z</dc:date>
    </item>
  </channel>
</rss>

