<?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 remove an entire column from results if all the values of the column are zero? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290942#M165751</link>
    <description>&lt;P&gt;@Naren26, Please find below one of the options (with a run anywhere example dashboard), which sorts the &lt;CODE&gt;field&lt;/CODE&gt; you want to check in descending order for all Null values to pick  first value and see whether it is null or not.&lt;/P&gt;

&lt;P&gt;I have used a base search with &lt;CODE&gt;id="baseSearch"&lt;/CODE&gt;, where search event handler &lt;CODE&gt;&amp;lt;done&amp;gt;&lt;/CODE&gt; is used to capture the value of field &lt;CODE&gt;test&lt;/CODE&gt;, using predefined token &lt;CODE&gt;$result.&amp;lt;fieldname&amp;gt;$&lt;/CODE&gt; i.e. &lt;CODE&gt;$result.test$&lt;/CODE&gt; to access the first row result. If it is null the &lt;CODE&gt;$partialQuery$&lt;/CODE&gt; token is set to &lt;CODE&gt;| fields - test&lt;/CODE&gt; to remove &lt;CODE&gt;test&lt;/CODE&gt; field in the post-process search.&lt;/P&gt;

&lt;P&gt;PS: Just to test the difference of &lt;CODE&gt;test&lt;/CODE&gt; field with and without values, I have added &lt;CODE&gt;| eval test="DummyValue"&lt;/CODE&gt; to the base search below. You can remove this pipe to confirm that &lt;CODE&gt;test&lt;/CODE&gt; field gets removed if all values are &lt;CODE&gt;null&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Remove Column with all Null values&amp;lt;/label&amp;gt;
  &amp;lt;search id="baseSearch"&amp;gt;
    &amp;lt;query&amp;gt;| gentimes start="10/01/2017"
| eval _time=starttime
| eval test="DummyValue"
| table _time test
| sort - test&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
    &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;!-- Picks only the text field value from first row which is sorted in descending order--&amp;gt;
      &amp;lt;eval token="partialQuery"&amp;gt;if(isnull($result.test$)," | fields - test | table _time", " | table _time test")&amp;lt;/eval&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt;$partialQuery$
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 Oct 2017 07:50:21 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-10-09T07:50:21Z</dc:date>
    <item>
      <title>How to remove an entire column from results if all the values of the column are zero?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290940#M165749</link>
      <description>&lt;P&gt;Is there any possibility to remove an entire column if all the values of the column are zero? &lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 05:48:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290940#M165749</guid>
      <dc:creator>Naren26</dc:creator>
      <dc:date>2017-10-09T05:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove an entire column from results if all the values of the column are zero?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290941#M165750</link>
      <description>&lt;P&gt;Column? Is that a column from a CSV? Or do you mean field? Or do you have something else in mind?&lt;/P&gt;

&lt;P&gt;Do you want to do this at search time, or index time? &lt;/P&gt;

&lt;P&gt;What is the purpose for removing the "column?" (in case there is something else that will do what you want)&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 06:15:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290941#M165750</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-10-09T06:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove an entire column from results if all the values of the column are zero?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290942#M165751</link>
      <description>&lt;P&gt;@Naren26, Please find below one of the options (with a run anywhere example dashboard), which sorts the &lt;CODE&gt;field&lt;/CODE&gt; you want to check in descending order for all Null values to pick  first value and see whether it is null or not.&lt;/P&gt;

&lt;P&gt;I have used a base search with &lt;CODE&gt;id="baseSearch"&lt;/CODE&gt;, where search event handler &lt;CODE&gt;&amp;lt;done&amp;gt;&lt;/CODE&gt; is used to capture the value of field &lt;CODE&gt;test&lt;/CODE&gt;, using predefined token &lt;CODE&gt;$result.&amp;lt;fieldname&amp;gt;$&lt;/CODE&gt; i.e. &lt;CODE&gt;$result.test$&lt;/CODE&gt; to access the first row result. If it is null the &lt;CODE&gt;$partialQuery$&lt;/CODE&gt; token is set to &lt;CODE&gt;| fields - test&lt;/CODE&gt; to remove &lt;CODE&gt;test&lt;/CODE&gt; field in the post-process search.&lt;/P&gt;

&lt;P&gt;PS: Just to test the difference of &lt;CODE&gt;test&lt;/CODE&gt; field with and without values, I have added &lt;CODE&gt;| eval test="DummyValue"&lt;/CODE&gt; to the base search below. You can remove this pipe to confirm that &lt;CODE&gt;test&lt;/CODE&gt; field gets removed if all values are &lt;CODE&gt;null&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Remove Column with all Null values&amp;lt;/label&amp;gt;
  &amp;lt;search id="baseSearch"&amp;gt;
    &amp;lt;query&amp;gt;| gentimes start="10/01/2017"
| eval _time=starttime
| eval test="DummyValue"
| table _time test
| sort - test&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
    &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;!-- Picks only the text field value from first row which is sorted in descending order--&amp;gt;
      &amp;lt;eval token="partialQuery"&amp;gt;if(isnull($result.test$)," | fields - test | table _time", " | table _time test")&amp;lt;/eval&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt;$partialQuery$
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Oct 2017 07:50:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290942#M165751</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-09T07:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove an entire column from results if all the values of the column are zero?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290943#M165752</link>
      <description>&lt;P&gt;Hey @Naren26, if @niketnilay solved your problem, remember to "√Accept" an answer to award karma points &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 00:13:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/290943#M165752</guid>
      <dc:creator>lfedak_splunk</dc:creator>
      <dc:date>2017-10-10T00:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove an entire column from results if all the values of the column are zero?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/512028#M165753</link>
      <description>&lt;P&gt;hi guys i need help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=data sourcetype=data source=data1 TestcaseId=4729484 | eval Timestamp=strftime(Timestamp/1000, "%H:%M:%S %d-%m-%Y")&lt;BR /&gt;| eval TCDuration=strftime(TCDuration/1000, "%M:%S")&lt;BR /&gt;| eval CC_RecognizedPrompt = a_hlr&lt;BR /&gt;| table Description Verdict Timestamp errorText a_number b_number ExternalNumber CC_RecognizedPrompt a_location b_location a_RxLeveld b_RxLeveld TestcaseId OrderId TCDuration&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need help where some of the columns/fields may be empty based on the TestcaseId passed. i need help removing those empty columns and still keep them in the same ORDER as i have listed in the table.&lt;/P&gt;&lt;P&gt;i initially have the last line, but its not in the order i want it to be.&lt;/P&gt;&lt;P&gt;| streamstats count as data | stats values(*) as * by data | fields - data&lt;/P&gt;&lt;P&gt;any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 20:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-an-entire-column-from-results-if-all-the-values-of/m-p/512028#M165753</guid>
      <dc:creator>thaghost99</dc:creator>
      <dc:date>2020-08-01T20:16:21Z</dc:date>
    </item>
  </channel>
</rss>

