<?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 How to remove empty fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671679#M230145</link>
    <description>&lt;P&gt;| table Status, timeval, CompanyCode, CN&lt;BR /&gt;|appendpipe [stats count| eval error="thats not cool" | where count==0 |table error |fields - Status, timeval, CompanyCode, CN]&lt;BR /&gt;&lt;BR /&gt;these are the last two lines of a search , so in this search if in fields (Status, timeval, CompanyCode, CN) there is no values or the all the fields are empty then i have to display a message which in this case is&amp;nbsp;"thats not cool"&lt;BR /&gt;, it is working but in the result as you can see all the empty fields are also displaying in the result . But I want only the error field if other fields are empty. Can anyone help?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Siddharthnegi_0-1702460432617.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28477i57B17DFE3990E8FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Siddharthnegi_0-1702460432617.png" alt="Siddharthnegi_0-1702460432617.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Dec 2023 13:55:25 GMT</pubDate>
    <dc:creator>Siddharthnegi</dc:creator>
    <dc:date>2023-12-13T13:55:25Z</dc:date>
    <item>
      <title>How to remove empty fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671679#M230145</link>
      <description>&lt;P&gt;| table Status, timeval, CompanyCode, CN&lt;BR /&gt;|appendpipe [stats count| eval error="thats not cool" | where count==0 |table error |fields - Status, timeval, CompanyCode, CN]&lt;BR /&gt;&lt;BR /&gt;these are the last two lines of a search , so in this search if in fields (Status, timeval, CompanyCode, CN) there is no values or the all the fields are empty then i have to display a message which in this case is&amp;nbsp;"thats not cool"&lt;BR /&gt;, it is working but in the result as you can see all the empty fields are also displaying in the result . But I want only the error field if other fields are empty. Can anyone help?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Siddharthnegi_0-1702460432617.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28477i57B17DFE3990E8FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Siddharthnegi_0-1702460432617.png" alt="Siddharthnegi_0-1702460432617.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 13:55:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671679#M230145</guid>
      <dc:creator>Siddharthnegi</dc:creator>
      <dc:date>2023-12-13T13:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671732#M230159</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I think you could use something like this instead:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Removing-all-null-columns-from-stats-table/m-p/566579" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/Removing-all-null-columns-from-stats-table/m-p/566579&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;------------&lt;BR /&gt;If this was helpful, some karma would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 13:54:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671732#M230159</guid>
      <dc:creator>glc_slash_it</dc:creator>
      <dc:date>2023-12-13T13:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671764#M230169</link>
      <description>&lt;P&gt;&lt;BR /&gt;Thanks for the reply but my problem is little different my search has table command before using appendpipe for displaying scustom message , and now the problem is if table is empty it should display only custom message but it is showing empty table plus the message&amp;nbsp; like image below.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Siddharthnegi_0-1702485565674.png" style="width: 792px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28494i0D105CFD3DA15368/image-dimensions/792x95?v=v2" width="792" height="95" role="button" title="Siddharthnegi_0-1702485565674.png" alt="Siddharthnegi_0-1702485565674.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 16:40:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671764#M230169</guid>
      <dc:creator>Siddharthnegi</dc:creator>
      <dc:date>2023-12-13T16:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671766#M230170</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Why you cannot/don't want to use&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253114"&gt;@glc_slash_it&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;answer? At least with test data it seems to work. You could test it like&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your basesearch OR | makeresults&amp;gt;
| table Status, timeval, CompanyCode, CN 
| appendpipe 
    [ stats count 
    | eval error="thats not cool" 
    | where count==0 
    | table error 
    | fields - Status, timeval, CompanyCode, CN] 
| transpose 0 
| eval allnulls=1 
| foreach row* 
    [ eval allnulls=if(isnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'),allnulls,0) ] 
| where allnulls=0 
| fields - allnulls 
| transpose 0 header_field=column 
| fields - column&lt;/LI-CODE&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 16:56:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671766#M230170</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2023-12-13T16:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671808#M230184</link>
      <description>&lt;P&gt;You can use the&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;solution just by adding his code after your appendpipe, but if you normally have a LOT of rows then the transpose and row processing may be very quite heavy.&lt;/P&gt;&lt;P&gt;There is an alternate solution, not sure how this will perform with a large result set and how it differs to the other one.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your base search with results...
| appendpipe [
 | stats count | where count=0
 | eval error="None"
 | fields - count
 ]
``` Rename all fields to X_* ```
| rename * as X_*
``` Now move those fields to the real name if it's not null ```
| foreach X_* [ eval "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"=if(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), null(), &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) ]
``` and remove all the original X_ fields, so that non-null fields remain ```
| fields - X_*&lt;/LI-CODE&gt;&lt;P&gt;With Splunk there is often more than one way to solve a problem&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 22:09:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671808#M230184</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-12-13T22:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671835#M230197</link>
      <description>&lt;P&gt;just a small question what will come in &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 05:37:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671835#M230197</guid>
      <dc:creator>Siddharthnegi</dc:creator>
      <dc:date>2023-12-14T05:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671837#M230198</link>
      <description>&lt;P&gt;Check out the docs for foreach&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.1/SearchReference/foreach" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.1/SearchReference/foreach&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; template is replaced with the value of the field being iterated through. In your context, it is the value of the row* field being evaluated.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 06:15:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671837#M230198</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-12-14T06:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671885#M230219</link>
      <description>&lt;P&gt;thanks this solution is working for some test cases.&lt;BR /&gt;in other test case&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Siddharthnegi_0-1702552868954.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28518i9D204BF05989FF83/image-size/large?v=v2&amp;amp;px=999" role="button" title="Siddharthnegi_0-1702552868954.png" alt="Siddharthnegi_0-1702552868954.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;like in this one count field is zero , so i want custom message if count field is zero , any suggestions.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 11:22:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-empty-fields/m-p/671885#M230219</guid>
      <dc:creator>Siddharthnegi</dc:creator>
      <dc:date>2023-12-14T11:22:38Z</dc:date>
    </item>
  </channel>
</rss>

