<?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 fill empty field values to 0 in Splunk ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/593704#M206654</link>
    <description>&lt;P&gt;Thanks - that helped a lot. One note: At least since Splunk 7.x you can use `trim` instead of `rex`:&lt;/P&gt;&lt;PRE&gt;... | foreach Every Field That Might Be Empty or Have Only Whitespace Listed Here [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(trim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]&lt;/PRE&gt;&lt;P&gt;Also, in case you want to apply it for all fields, you can use `*`:&lt;/P&gt;&lt;PRE&gt;... | foreach * [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(trim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 03:29:02 GMT</pubDate>
    <dc:creator>mschiesser</dc:creator>
    <dc:date>2022-04-14T03:29:02Z</dc:date>
    <item>
      <title>How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498414#M138867</link>
      <description>&lt;P&gt;I have data in below format in Splunk &lt;BR /&gt;
where I extracted this as Brand,Files,Size.&lt;/P&gt;

&lt;P&gt;Now at some places, where size is showing empty, I want to replace them with 0.&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8558iFB2A65813A9BC299/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I have used | fillnull value 0.&lt;BR /&gt;
| eval Size=if(isnull(Size), "0", Size)&lt;/P&gt;

&lt;P&gt;But  still values are showing empty.&lt;/P&gt;

&lt;P&gt;I have used below query&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=***  host=*** source=**** &lt;BR /&gt;
| rex field=_raw max_match=0 "(?[a-z]+),(?\w+\-?\d?.*)\,(?\d?.*)"&lt;BR /&gt;
 | table Brand,Size,Files&lt;BR /&gt;
 | eval _counter = mvrange(0,mvcount(Brand))&lt;BR /&gt;
 | stats list(*) as * by _counter&lt;BR /&gt;
 | foreach * [ eval &amp;lt;&amp;gt; = mvindex('&amp;lt;&amp;gt;' , _counter)]&lt;BR /&gt;
 | xyseries Brand Files Size&lt;BR /&gt;
 | transpose 0 header_field=Brand column_name=Files  | fillnull value=0&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and the result i m getting as like below&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8559i98ACA3EAC17E9B7F/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;After using | fillnull value 0, &lt;BR /&gt;
I am getting 0 for those files which are not there for 2nd,3rd,4th brands.&lt;BR /&gt;
But not where size is showing empty.&lt;/P&gt;

&lt;P&gt;Can anyone help me with this ?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 09:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498414#M138867</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-20T09:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498415#M138868</link>
      <description>&lt;P&gt;,Hi, &lt;BR /&gt;
I think you just missing to tell it what is the field you want fillnull to work on.&lt;/P&gt;

&lt;P&gt;try|fillnull value=1 [] []&lt;BR /&gt;
Your dataset dont not have any column name test_field, so they are all null value. After execute this command, your test_field will be filled with 1. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:40:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498415#M138868</guid>
      <dc:creator>thuhuongle</dc:creator>
      <dc:date>2020-09-30T04:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498416#M138869</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You probably have the fields as not null.&lt;BR /&gt;
It usually will be a white space.Check whether its whitespace using the following command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   |eval fieldLength=len(Size)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have white space, replace the if clause as below or use replace command to replace white space to null&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval Size=if(isnull(Size),"0",if(Size="  ","0",Size))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Mar 2020 11:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498416#M138869</guid>
      <dc:creator>dindu</dc:creator>
      <dc:date>2020-03-20T11:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498417#M138870</link>
      <description>&lt;P&gt;The problem is that there are 2 different &lt;CODE&gt;nullish&lt;/CODE&gt; things in Splunk.  One is where the field has &lt;CODE&gt;no value&lt;/CODE&gt; and is truly &lt;CODE&gt;null&lt;/CODE&gt;.  The other is when it has a value, but the value is &lt;CODE&gt;""&lt;/CODE&gt; or &lt;CODE&gt;empty&lt;/CODE&gt; and is unprintable and zero-length, but &lt;EM&gt;not&lt;/EM&gt; &lt;CODE&gt;null&lt;/CODE&gt;.  What you need to use to cover all of your bases is this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | foreach Every Field That Might Be Empty Listed Here [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test this like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults
| eval notNULL=""
| fillnull value=0 notNULL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Versus this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults
| eval notNULL=""
| foreach notNULL [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of course, this only works if it is &lt;CODE&gt;empty&lt;/CODE&gt;; very occasionally you may find a field with only whitespace in it.  For those cases, you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | foreach Every Field That Might Be Empty or Have Only Whitespace Listed Here [ rex field=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; mode=sed "s/^[\r\n\s]+$//" | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Mar 2020 13:00:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498417#M138870</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-20T13:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498418#M138871</link>
      <description>&lt;P&gt;Hi @dindu &lt;BR /&gt;
I tried above suggestions but it did not worked .&lt;BR /&gt;
Might be because field is string.&lt;/P&gt;

&lt;P&gt;I tried to convert it into number using convert but that also not worked.&lt;/P&gt;

&lt;P&gt;Attached screenshot.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 10:49:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498418#M138871</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-23T10:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498419#M138872</link>
      <description>&lt;P&gt;Hi @woodcock &lt;/P&gt;

&lt;P&gt;Thanks for your suggestions.&lt;BR /&gt;
I tried both of them, but they are not working.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 03:28:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498419#M138872</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-24T03:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498420#M138873</link>
      <description>&lt;P&gt;What are you &lt;CODE&gt;field names&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 03:47:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498420#M138873</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-24T03:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498421#M138874</link>
      <description>&lt;P&gt;Brand, Files and Size&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 04:35:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498421#M138874</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-24T04:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498422#M138875</link>
      <description>&lt;P&gt;@dindu &lt;BR /&gt;
Since there are multiple values for  "Size" field.&lt;BR /&gt;
Is there a way to check length here ?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 09:56:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498422#M138875</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-24T09:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498423#M138876</link>
      <description>&lt;P&gt;@woodcock &lt;/P&gt;

&lt;P&gt;I used below &lt;BR /&gt;
&lt;CODE&gt;| foreach * [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;And finally it worked&lt;BR /&gt;
Earlier I used Size which didn't worked instead of *&lt;/P&gt;

&lt;P&gt;Thanks once again&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 10:22:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498423#M138876</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-24T10:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498424#M138877</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;The below command will work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval fieldLength=len(your_field_name)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Mar 2020 11:34:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498424#M138877</guid>
      <dc:creator>dindu</dc:creator>
      <dc:date>2020-03-24T11:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498425#M138878</link>
      <description>&lt;P&gt;Be sure to come back and click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question and also &lt;CODE&gt;UpVote&lt;/CODE&gt; any helpful comments or answers.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 14:14:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498425#M138878</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-24T14:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498426#M138879</link>
      <description>&lt;P&gt;Done.&lt;BR /&gt;
Can you also help me in answering&lt;/P&gt;

&lt;P&gt;&lt;A href="https://urldefense.proofpoint.com/v2/url?u=https-3A__answers.splunk.com_comments_813518_view.html&amp;amp;d=DwMCaQ&amp;amp;c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&amp;amp;r=d1I-PtwBnEn5KCQBE4yXGX3olOomGKItrlhcKT_6d7c&amp;amp;m=oum9sTGS9sYRLXd_wGXOvpKjBif-9uMnxOWlgcelcy8&amp;amp;s=ec4M31qf6JglmGTGvwU5DsAvNZ3FaYoznZcwgWdlIg4&amp;amp;e="&gt;https://urldefense.proofpoint.com/v2/url?u=https-3A__answers.splunk.com_comments_813518_view.html&amp;amp;d=DwMCaQ&amp;amp;c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&amp;amp;r=d1I-PtwBnEn5KCQBE4yXGX3olOomGKItrlhcKT_6d7c&amp;amp;m=oum9sTGS9sYRLXd_wGXOvpKjBif-9uMnxOWlgcelcy8&amp;amp;s=ec4M31qf6JglmGTGvwU5DsAvNZ3FaYoznZcwgWdlIg4&amp;amp;e=&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 10:09:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498426#M138879</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-25T10:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498427#M138880</link>
      <description>&lt;P&gt;You posted the wrong URL here (it is a link to THIS post).&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 14:16:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498427#M138880</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-25T14:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498428#M138881</link>
      <description>&lt;P&gt;oops, my bad.&lt;BR /&gt;
This is the correct one.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/812823/not-able-to-convert-field-from-string-to-number.html"&gt;https://answers.splunk.com/answers/812823/not-able-to-convert-field-from-string-to-number.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 02:55:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/498428#M138881</guid>
      <dc:creator>nilbak1</dc:creator>
      <dc:date>2020-03-26T02:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill empty field values to 0 in Splunk ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/593704#M206654</link>
      <description>&lt;P&gt;Thanks - that helped a lot. One note: At least since Splunk 7.x you can use `trim` instead of `rex`:&lt;/P&gt;&lt;PRE&gt;... | foreach Every Field That Might Be Empty or Have Only Whitespace Listed Here [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(trim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]&lt;/PRE&gt;&lt;P&gt;Also, in case you want to apply it for all fields, you can use `*`:&lt;/P&gt;&lt;PRE&gt;... | foreach * [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) OR len(trim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))==0, "0", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 03:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fill-empty-field-values-to-0-in-Splunk/m-p/593704#M206654</guid>
      <dc:creator>mschiesser</dc:creator>
      <dc:date>2022-04-14T03:29:02Z</dc:date>
    </item>
  </channel>
</rss>

