<?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 only display fields with values in a table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89156#M22847</link>
    <description>&lt;P&gt;I tried this command and it still displays the fields which have a null value. &lt;BR /&gt;
stats values (fieldname) by itself works, but when I give the command as stats values (*), the result is all the fields with all distinct values, fields with null values also get displayed which kind of beats my purpose, which is to select and display those fields which have at least one non null value. Can someone help me figure out where I might be going wrong? &lt;/P&gt;</description>
    <pubDate>Sat, 08 Jul 2017 03:06:15 GMT</pubDate>
    <dc:creator>nisha_kapoor</dc:creator>
    <dc:date>2017-07-08T03:06:15Z</dc:date>
    <item>
      <title>How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89146#M22837</link>
      <description>&lt;P&gt;I'm interested in doing a search for a number of fields and displaying the output in a &lt;CODE&gt;| table ...&lt;/CODE&gt; of only the fields with values.&lt;/P&gt;

&lt;P&gt;Basically I have a list of error description fields that I want to print out, but only if they have something in them.  I don't want to routinely display 20 extra fields that are usually empty for the odd chance when they are not.&lt;/P&gt;

&lt;P&gt;My search will be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;where ErrorField1=* OR ErrorField2=*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;etc&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2012 20:29:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89146#M22837</guid>
      <dc:creator>alecl</dc:creator>
      <dc:date>2012-10-12T20:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89147#M22838</link>
      <description>&lt;P&gt;Can you use "table" command to display specified field value?&lt;/P&gt;

&lt;P&gt;... | table ErrorField1 ErrorField2&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2012 23:48:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89147#M22838</guid>
      <dc:creator>Takajian</dc:creator>
      <dc:date>2012-10-12T23:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89148#M22839</link>
      <description>&lt;P&gt;That will always display both fields whether they have a value or not which is what I want to avoid otherwise the table will scroll 30 columns wide with all the fields I'm looking for with only sparse data actually filling it.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Oct 2012 12:20:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89148#M22839</guid>
      <dc:creator>alecl</dc:creator>
      <dc:date>2012-10-13T12:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89149#M22840</link>
      <description>&lt;P&gt;Do you want to filter the fields which value is NULL? Then, does following search meet your requirement?&lt;/P&gt;

&lt;P&gt;.. | table ErrorField1 ErrorField2 | where ErrorField1 NOT null AND ErrorField2 NOT NULL&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2012 09:25:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89149#M22840</guid>
      <dc:creator>Takajian</dc:creator>
      <dc:date>2012-10-16T09:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89150#M22841</link>
      <description>&lt;P&gt;That is fine for the search, but I'm concerned about the list of fields in the table display.&lt;/P&gt;

&lt;P&gt;ex1) ErrorField1 is null, ErrorField2 has a value&lt;BR /&gt;
table should show ErrorField2 only&lt;/P&gt;

&lt;P&gt;ex2) ErrorField1 has a value, ErrorField2 is null&lt;BR /&gt;
table should show ErrorField1 only&lt;/P&gt;

&lt;P&gt;The table options should be able to figure out when not to show a field somehow.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 17:24:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89150#M22841</guid>
      <dc:creator>alecl</dc:creator>
      <dc:date>2012-10-19T17:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89151#M22842</link>
      <description>&lt;P&gt;table a b c | where a="Value"... This worked liked a charm!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 17:56:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89151#M22842</guid>
      <dc:creator>marcellodesales</dc:creator>
      <dc:date>2014-03-17T17:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89152#M22843</link>
      <description>&lt;P&gt;Here's my example with a "where", which verifies the value of a given field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=quadf_qdc_prod source="/usr/share/whp-tomcat-7/logs/catalina.out" " &amp;gt; x-forwarded-for:" | rex "x-forwarded-for: (?&amp;lt;IP_ADDRESSES&amp;gt;(.*))" | table IP_ADDRESSES | eval CLIENT_IP=mvindex(split(IP_ADDRESSES, ","), 0) | stats count by CLIENT_IP | lookup geoip clientip AS CLIENT_IP | eval client_geo=client_lat+" , "+client_lon | stats count by CLIENT_IP, client_city, client_region, client_country, client_geo | where client_country="Brazil"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Mar 2014 17:59:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89152#M22843</guid>
      <dc:creator>marcellodesales</dc:creator>
      <dc:date>2014-03-17T17:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89153#M22844</link>
      <description>&lt;P&gt;Assuming that you will only have one "ErrorField" popualted with data for each event, yo ucan use the eval coalesce() function to create a new field that is equal to the value found in one of the ErrorField* fields. For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where ErrorField1=* OR ErrorField2=* | eval outputField=coalesce(ErrorField1,ErrorField2) | table outputField
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If if is possible for there to be values in more than one "ErrorField" for each event, you can use strcat to concatenate all the "ErrorField" values together into a new field. For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where ErrorField1=* OR ErrorField2=* | strcat ErrorField1 ErrorField2 outputField | table outputField
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Mar 2014 22:15:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89153#M22844</guid>
      <dc:creator>rtadams89</dc:creator>
      <dc:date>2014-03-17T22:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89154#M22845</link>
      <description>&lt;P&gt;A bit hacky but it should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | streamstats count as temp_id | stats values(*) by temp_count | rename values(*) as * | fields - temp_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why it works?&lt;/P&gt;

&lt;P&gt;Because &lt;CODE&gt;stats values(...)&lt;/CODE&gt; won't show fields that don't have at least one non-null value. I also use &lt;CODE&gt;streamstats count as temp_id&lt;/CODE&gt; to generate a unique "ID" for each row so we don't do some accidental grouping in &lt;CODE&gt;stats&lt;/CODE&gt;. And of course if you already have a unique id like &lt;CODE&gt;... | stats ... by id&lt;/CODE&gt; previously then you won't need &lt;CODE&gt;temp_id&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2015 21:49:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89154#M22845</guid>
      <dc:creator>skawasaki_splun</dc:creator>
      <dc:date>2015-03-10T21:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89155#M22846</link>
      <description>&lt;P&gt;I think you have a typo: It should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats count as temp_id | stats values(*) by temp_id| rename values(*) as * | fields - temp_id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2016 19:11:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89155#M22846</guid>
      <dc:creator>ndoshi</dc:creator>
      <dc:date>2016-05-24T19:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89156#M22847</link>
      <description>&lt;P&gt;I tried this command and it still displays the fields which have a null value. &lt;BR /&gt;
stats values (fieldname) by itself works, but when I give the command as stats values (*), the result is all the fields with all distinct values, fields with null values also get displayed which kind of beats my purpose, which is to select and display those fields which have at least one non null value. Can someone help me figure out where I might be going wrong? &lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2017 03:06:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89156#M22847</guid>
      <dc:creator>nisha_kapoor</dc:creator>
      <dc:date>2017-07-08T03:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89157#M22848</link>
      <description>&lt;P&gt;Didn't work in my case - The empty columns persisted (Splunk 7.0.2). &lt;BR /&gt;
Instead, I found this solution &lt;A href="https://answers.splunk.com/answers/418542/how-to-hide-a-column-in-a-table-if-every-value-in.html#answer-616971"&gt;Link&lt;/A&gt; here in the forum: &lt;A href="https://answers.splunk.com/answering/593190/view.html"&gt;https://answers.splunk.com/answering/593190/view.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 07:43:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89157#M22848</guid>
      <dc:creator>romanwaldecker</dc:creator>
      <dc:date>2018-02-20T07:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89158#M22849</link>
      <description>&lt;P&gt;This worked like a charm! Thanks! It took me a while to figure out that the command has to go AFTER you table it.&lt;/P&gt;

&lt;P&gt;But, it's interesting, I have multi-value (mv) fields that have the data value repeated twice in it - which I've been having to hack out using:&lt;/P&gt;

&lt;P&gt;fillnull value="" | mvexpand field1 | mvexpand field2 | dedup _raw&lt;/P&gt;

&lt;P&gt;This command though, somehow, for some unknown reason, does the same thing, and dedupes any mv data in the display table - at least if the value is repeated/the same. It could be a problem for anyone who has multiple/mv values in their data.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 21:51:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89158#M22849</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2018-08-23T21:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89159#M22850</link>
      <description>&lt;P&gt;Okay I'm sure the "for some unknown reason" part actually makes sense to someone who knows more than me, and has to do with the way stats values(*) works&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 21:54:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89159#M22850</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2018-08-23T21:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89160#M22851</link>
      <description>&lt;P&gt;I downvoted this post because this answers the questions on what the fields with values are but does not display only the fields with values with their values.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 17:07:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/89160#M22851</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2019-11-07T17:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to only display fields with values in a table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/514045#M144288</link>
      <description>&lt;P&gt;Just to addon and remove some of the default fields from Splunk&lt;/P&gt;&lt;P&gt;(This way you can recover user custom fields)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;..your base search..
| streamstats count as temp_id
| stats values(*) by temp_id
| rename values(*) as *
| fields - temp_id, date_*, index, host, info_*,source,sourcetype,linecount,user_watchlist,time*pos,unix_*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 08:56:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-only-display-fields-with-values-in-a-table/m-p/514045#M144288</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2020-08-14T08:56:07Z</dc:date>
    </item>
  </channel>
</rss>

