<?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 Use field A if B does not exist in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152783#M42807</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;in the past I used a lookup to add the field "price" to my events.&lt;BR /&gt;
Now there will be a new field "price II" in the eventstructure. In the statistics I would like to tell Splunk to use "price II" if it exists, otherwise use "price"&lt;/P&gt;

&lt;P&gt;My idea would be to create a new field "final_price" and use this field for further calculations. But I've no idea what kind of function should be used.&lt;/P&gt;

&lt;P&gt;| eval final_price=...&lt;/P&gt;

&lt;P&gt;Thanks in advance &lt;/P&gt;

&lt;P&gt;Heinz&lt;/P&gt;</description>
    <pubDate>Mon, 17 Feb 2014 08:53:27 GMT</pubDate>
    <dc:creator>HeinzWaescher</dc:creator>
    <dc:date>2014-02-17T08:53:27Z</dc:date>
    <item>
      <title>Use field A if B does not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152783#M42807</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;in the past I used a lookup to add the field "price" to my events.&lt;BR /&gt;
Now there will be a new field "price II" in the eventstructure. In the statistics I would like to tell Splunk to use "price II" if it exists, otherwise use "price"&lt;/P&gt;

&lt;P&gt;My idea would be to create a new field "final_price" and use this field for further calculations. But I've no idea what kind of function should be used.&lt;/P&gt;

&lt;P&gt;| eval final_price=...&lt;/P&gt;

&lt;P&gt;Thanks in advance &lt;/P&gt;

&lt;P&gt;Heinz&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2014 08:53:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152783#M42807</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2014-02-17T08:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Use field A if B does not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152784#M42808</link>
      <description>&lt;P&gt;Hi HeinzWaescher,&lt;/P&gt;

&lt;P&gt;check the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/CommonEvalFunctions"&gt;isnotnull()&lt;/A&gt; or &lt;CODE&gt;where&lt;/CODE&gt; function for &lt;CODE&gt;eval&lt;/CODE&gt;, so you could use something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; YourSearchHere | eval final_price=if(isnotnull(price II),price II,price)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;But&lt;/STRONG&gt; I'm not sure if this will work for you, because you're using a space in the fieldname. You should avoid spaces in field names and use &lt;CODE&gt;_ or -&lt;/CODE&gt; instead.&lt;/P&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2014 09:44:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152784#M42808</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-02-17T09:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Use field A if B does not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152785#M42809</link>
      <description>&lt;P&gt;Splunk has a habit of replacing Spaces with underscores. Your field will probably be "price_II".&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2014 12:10:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152785#M42809</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2014-02-17T12:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Use field A if B does not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152786#M42810</link>
      <description>&lt;P&gt;Here's a shorter version:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval final_price=coalesce(price_II,price) | ..
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Feb 2014 12:41:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152786#M42810</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-02-17T12:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use field A if B does not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152787#M42811</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;this works fine! There is no space in the fieldname, it was just a bad example &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 09:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152787#M42811</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2014-02-19T09:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use field A if B does not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152788#M42812</link>
      <description>&lt;P&gt;This command works fine as well. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 09:50:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-field-A-if-B-does-not-exist/m-p/152788#M42812</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2014-02-19T09:50:25Z</dc:date>
    </item>
  </channel>
</rss>

