<?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: If column is missing then eval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462614#M140541</link>
    <description>&lt;P&gt;thanks, luckily my column names are months, ie last 12 months, so my last column as of today is 'Apr 2020' followed by the 'Missing' column.&lt;/P&gt;

&lt;P&gt;so i got the 'Apr 2020' using eval as below, but when i eval it with "missing" , it prints the actual value.&lt;BR /&gt;
how to treat the value to be a column during eval on 2nd line...&lt;/P&gt;

&lt;P&gt;|eval ThisMonth=strftime(relative_time(now(), "-0d"), "%b %Y")&lt;BR /&gt;
| eval Missing = if(isnull(Missing),ThisMonth, Missing)&lt;BR /&gt;
|fields - ThisMonth&lt;/P&gt;

&lt;P&gt;output below :&lt;/P&gt;

&lt;P&gt;Apr 2020    Missing&lt;BR /&gt;
99.62   Apr 2020&lt;BR /&gt;
99.37   Apr 2020&lt;BR /&gt;
99.16   Apr 2020&lt;BR /&gt;
99.42   Apr 2020&lt;/P&gt;

&lt;P&gt;basically want the values of Apr 2020 to be under Missing, like below.&lt;/P&gt;

&lt;P&gt;Apr 2020    Missing&lt;BR /&gt;
99.62   99.62&lt;BR /&gt;
99.37   99.37&lt;BR /&gt;
99.16   99.16&lt;BR /&gt;
99.42   99.42&lt;/P&gt;</description>
    <pubDate>Wed, 01 Apr 2020 13:53:54 GMT</pubDate>
    <dc:creator>jiaqya</dc:creator>
    <dc:date>2020-04-01T13:53:54Z</dc:date>
    <item>
      <title>If column is missing then eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462609#M140536</link>
      <description>&lt;P&gt;if a field is missing in output, what is the query to eval another field to create this missing field.&lt;/P&gt;
&lt;P&gt;below query can do it,&lt;BR /&gt;&lt;BR /&gt;|eval missing=anothercolumn.&lt;/P&gt;
&lt;P&gt;but to run this query , i need to run it only when the "missing" column is missing.&lt;BR /&gt;what is the logic to use..&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 22:02:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462609#M140536</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-06-08T22:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: If column is missing then eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462610#M140537</link>
      <description>&lt;P&gt;You can use 'if' and 'isnull' to identify whether the field exists, and if not replace it with another field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval there = "NOTNULL" 
| eval NEWFIELD = if(isnull(notthere),"FIELD IS NULL", "FIELD IS AVAIL") 
| eval NEWFIELD2 = if(isnull(there),"FIELD IS NULL", "FIELD IS AVAIL")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval there = "NOTNULL" 
| eval newfield = "NEW"
| eval NEWFIELD = if(isnull(notthere),"FIELD IS NULL", "FIELD IS AVAIL") 
| eval NEWFIELD2 = if(isnull(there),newfield, there)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 12:07:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462610#M140537</guid>
      <dc:creator>memarshall63</dc:creator>
      <dc:date>2020-04-01T12:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: If column is missing then eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462611#M140538</link>
      <description>&lt;P&gt;This works good,  thanks, can i ask for another help.&lt;/P&gt;

&lt;P&gt;the eval missing=newcolumn.&lt;/P&gt;

&lt;P&gt;the new column is the last column in the table which im evaling with missing.&lt;BR /&gt;
how do i eval the last column to be missing..&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 12:56:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462611#M140538</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-04-01T12:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: If column is missing then eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462612#M140539</link>
      <description>&lt;P&gt;simplifying this even further,.&lt;/P&gt;

&lt;P&gt;if column "missing" is missing, then eval it with 12th column( this wont change )&lt;/P&gt;

&lt;P&gt;to identify "missing" is actually missing, i am using your above code... of if and isnull&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 13:04:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462612#M140539</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-04-01T13:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: If column is missing then eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462613#M140540</link>
      <description>&lt;P&gt;That's a tougher question.&lt;/P&gt;

&lt;P&gt;The only way I'd know how to do that is to leave the values in a string, split it, and then use mvindex to index the 12th value in the split.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval message = "this,is,the,fourth,fifth,sixth,value" 
| eval new_mvfield = split(message,",") 
| eval FOURTH = mvindex(new_mvfield,3)
| eval FIFTH = mvindex(new_mvfield,4)
| eval LAST = mvindex(new_mvfield,-1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 13:20:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462613#M140540</guid>
      <dc:creator>memarshall63</dc:creator>
      <dc:date>2020-04-01T13:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: If column is missing then eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462614#M140541</link>
      <description>&lt;P&gt;thanks, luckily my column names are months, ie last 12 months, so my last column as of today is 'Apr 2020' followed by the 'Missing' column.&lt;/P&gt;

&lt;P&gt;so i got the 'Apr 2020' using eval as below, but when i eval it with "missing" , it prints the actual value.&lt;BR /&gt;
how to treat the value to be a column during eval on 2nd line...&lt;/P&gt;

&lt;P&gt;|eval ThisMonth=strftime(relative_time(now(), "-0d"), "%b %Y")&lt;BR /&gt;
| eval Missing = if(isnull(Missing),ThisMonth, Missing)&lt;BR /&gt;
|fields - ThisMonth&lt;/P&gt;

&lt;P&gt;output below :&lt;/P&gt;

&lt;P&gt;Apr 2020    Missing&lt;BR /&gt;
99.62   Apr 2020&lt;BR /&gt;
99.37   Apr 2020&lt;BR /&gt;
99.16   Apr 2020&lt;BR /&gt;
99.42   Apr 2020&lt;/P&gt;

&lt;P&gt;basically want the values of Apr 2020 to be under Missing, like below.&lt;/P&gt;

&lt;P&gt;Apr 2020    Missing&lt;BR /&gt;
99.62   99.62&lt;BR /&gt;
99.37   99.37&lt;BR /&gt;
99.16   99.16&lt;BR /&gt;
99.42   99.42&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 13:53:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-column-is-missing-then-eval/m-p/462614#M140541</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-04-01T13:53:54Z</dc:date>
    </item>
  </channel>
</rss>

