<?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 to create a conditional eval to fill a new field depending on other fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433921#M123887</link>
    <description>&lt;P&gt;Try this. The new field name will be called &lt;CODE&gt;NewField&lt;/CODE&gt; and assumes your field name is &lt;CODE&gt;field&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval NewField=if(isnull(Field),"null",'Field')
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Aug 2018 12:09:19 GMT</pubDate>
    <dc:creator>skoelpin</dc:creator>
    <dc:date>2018-08-29T12:09:19Z</dc:date>
    <item>
      <title>How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433919#M123885</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I want to create a new field that will take the value of other fields depending of which one is filled.&lt;/P&gt;

&lt;P&gt;For example, I have 5 fields but only one can be filled at a time. The other fields don't have any value.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Field1:
Field2:
Field3:
Field4: Ok
Field5:
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I write the eval to check if a field1 is null, take the value of the following field2, if it is also null, take the value of field3 until it reaches the not null field?&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 09:46:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433919#M123885</guid>
      <dc:creator>lyds</dc:creator>
      <dc:date>2018-08-29T09:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433920#M123886</link>
      <description>&lt;P&gt;//// I have 5 fields but only one can be filled at a time. The other fields don't have any value ////&lt;BR /&gt;
In your search use the fillnull command and assign a value to that field when it is null, then count that value for the field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search Field="*" | fillnull value=NULL | stats count by Field | where count=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Updated - with coalesce, try this one.. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search Field="*" | eval NewField=coalesce(Field1, Field2, Field3, Field4, Field5) | eval result=if(NewField="Ok", "all good", "some fields are not null")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 12:05:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433920#M123886</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-08-29T12:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433921#M123887</link>
      <description>&lt;P&gt;Try this. The new field name will be called &lt;CODE&gt;NewField&lt;/CODE&gt; and assumes your field name is &lt;CODE&gt;field&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval NewField=if(isnull(Field),"null",'Field')
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Aug 2018 12:09:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433921#M123887</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2018-08-29T12:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433922#M123888</link>
      <description>&lt;P&gt;Hi @skoelpin ... i think you missed the 5 fields part of the question.. &lt;BR /&gt;
---  I have 5 fields but only one can be filled at a time. The other fields don't have any value.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 13:12:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433922#M123888</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-08-29T13:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433923#M123889</link>
      <description>&lt;P&gt;It's the same exact logic with a case statement... &lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 13:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433923#M123889</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2018-08-29T13:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433924#M123890</link>
      <description>&lt;P&gt;I think I'd use the coalesce eval function. It's description is 'This function takes an arbitrary number of arguments and returns the first value that is not NULL.'&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 08:05:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433924#M123890</guid>
      <dc:creator>RHASQaL</dc:creator>
      <dc:date>2018-08-30T08:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433925#M123891</link>
      <description>&lt;P&gt;with coalesce, try this one.. &lt;BR /&gt;
&lt;CODE&gt;search Field="*" | eval NewField=coalesce(Field1, Field2, Field3, Field4, Field5) | eval result=if(NewField="Ok", "all good", "some fields are not null")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 09:26:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433925#M123891</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-08-30T09:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433926#M123892</link>
      <description>&lt;P&gt;Try  &lt;CODE&gt;coalesce&lt;/CODE&gt; command &lt;/P&gt;

&lt;P&gt;eval new_field=coalesce(Field1,Field2,....)&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.splunk.com/blog/2014/03/21/search-command-coalesce.html"&gt;https://www.splunk.com/blog/2014/03/21/search-command-coalesce.html&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 21:34:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433926#M123892</guid>
      <dc:creator>nawazns5038</dc:creator>
      <dc:date>2018-08-30T21:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433927#M123893</link>
      <description>&lt;P&gt;I've used coalesce command, and I get what I wanted to display! &lt;/P&gt;

&lt;P&gt;Thanks you all for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 11:50:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433927#M123893</guid>
      <dc:creator>lyds</dc:creator>
      <dc:date>2018-08-31T11:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a conditional eval to fill a new field depending on other fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433928#M123894</link>
      <description>&lt;P&gt;@lyds, If your problem is resolved, please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 12:27:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-conditional-eval-to-fill-a-new-field-depending/m-p/433928#M123894</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-08-31T12:27:17Z</dc:date>
    </item>
  </channel>
</rss>

