<?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 add final total count of results without adding another column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202147#M58608</link>
    <description>&lt;P&gt;I can't seem to figure out a way to add a bottom row for a total count of results (records) to the end of the results without adding another column for a count and then totaling that column. There must be an easier way.  &lt;/P&gt;

&lt;P&gt;I can't use &lt;CODE&gt;|stats count&lt;/CODE&gt; which is the number I'm looking for because that suppresses the details of the results.&lt;BR /&gt;
Using &lt;CODE&gt;|stats count by ....(all my fields needed  in output)&lt;/CODE&gt;  works but it adds an unwanted column for the count. If I try to use &lt;CODE&gt;|fields - count&lt;/CODE&gt; that breaks the total count.&lt;/P&gt;

&lt;P&gt;I know there must be a way for this - please help!&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2016 20:13:44 GMT</pubDate>
    <dc:creator>splunkin11</dc:creator>
    <dc:date>2016-11-01T20:13:44Z</dc:date>
    <item>
      <title>How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202147#M58608</link>
      <description>&lt;P&gt;I can't seem to figure out a way to add a bottom row for a total count of results (records) to the end of the results without adding another column for a count and then totaling that column. There must be an easier way.  &lt;/P&gt;

&lt;P&gt;I can't use &lt;CODE&gt;|stats count&lt;/CODE&gt; which is the number I'm looking for because that suppresses the details of the results.&lt;BR /&gt;
Using &lt;CODE&gt;|stats count by ....(all my fields needed  in output)&lt;/CODE&gt;  works but it adds an unwanted column for the count. If I try to use &lt;CODE&gt;|fields - count&lt;/CODE&gt; that breaks the total count.&lt;/P&gt;

&lt;P&gt;I know there must be a way for this - please help!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:13:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202147#M58608</guid>
      <dc:creator>splunkin11</dc:creator>
      <dc:date>2016-11-01T20:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202148#M58609</link>
      <description>&lt;P&gt;can you just add &lt;CODE&gt;|addcoltotals&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:17:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202148#M58609</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2016-11-01T20:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202149#M58610</link>
      <description>&lt;P&gt;No, that only totals up columns. I have no column to total that will give a total count. &lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:22:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202149#M58610</guid>
      <dc:creator>splunkin11</dc:creator>
      <dc:date>2016-11-01T20:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202150#M58611</link>
      <description>&lt;P&gt;Try using Splunk commands &lt;STRONG&gt;addcoltotals&lt;/STRONG&gt; or &lt;STRONG&gt;addtotals&lt;/STRONG&gt; as per your need. Refer to following Splunk documentations:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addcoltotals"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addcoltotals&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addtotals"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Addtotals&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also with latest &lt;STRONG&gt;Splunk Enterprise 6.5&lt;/STRONG&gt; version this feature is inbuilt in UI for tables being printed. Once a table is saved as Dashaboard panel turning on &lt;STRONG&gt;Summary&amp;gt;Totals&lt;/STRONG&gt; prints the column totals.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:25:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202150#M58611</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-01T20:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202151#M58612</link>
      <description>&lt;P&gt;Oh I now understand. You might have to use &lt;STRONG&gt;$job.resultCount$&lt;/STRONG&gt; property for **** event and then assign it to a token to be used later in your Panel as &lt;STRONG&gt;HTML&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;Check &lt;STRONG&gt;Search Result Setter&lt;/STRONG&gt; in &lt;STRONG&gt;Splunk 6.x Dashboard Examples&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      &amp;lt;chart&amp;gt;
        &amp;lt;title&amp;gt;Top sourcetypes ($sourcetype_count$ total sourcetypes)&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal |  top sourcetype&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-60m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;!-- Use the following search events to access job properties, and set tokens that can be accessible throughout the page --&amp;gt;
          &amp;lt;!-- Progress event has access to job properties only (not first result row) --&amp;gt;
          &amp;lt;progress&amp;gt;
            &amp;lt;set token="sourcetype_count"&amp;gt;$job.resultCount$&amp;lt;/set&amp;gt;
          &amp;lt;/progress&amp;gt;
          &amp;lt;cancelled&amp;gt;
            &amp;lt;unset token="sourcetype_count"&amp;gt;&amp;lt;/unset&amp;gt;
          &amp;lt;/cancelled&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="charting.chart"&amp;gt;bar&amp;lt;/option&amp;gt;
        &amp;lt;option name="charting.legend.placement"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/chart&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:28:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202151#M58612</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-01T20:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202152#M58613</link>
      <description>&lt;P&gt;ok ...  I don't have a need to total columns of numbers so this wouldn't apply. I know I can add a column to my output for the sake of using one of these functions but I don't want to add a column that displays a '1' for every record just so I can get a grand total count at the bottom.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202152#M58613</guid>
      <dc:creator>splunkin11</dc:creator>
      <dc:date>2016-11-01T20:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202153#M58614</link>
      <description>&lt;P&gt;I have edited my answer, you can try using $job.resultCount$ and print anywhere in the panel you like. In Splunk 6.x Dashaborad Examples code, it has been added as Panel Title. Please check and see if it solves your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:38:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202153#M58614</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-01T20:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202154#M58615</link>
      <description>&lt;P&gt;wowzers ... I'm not even sure how to incorporate that into my simple dashboard &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;   There must be a simpler way to get the same result such as with an |appendpipe or some other feature.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:47:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202154#M58615</guid>
      <dc:creator>splunkin11</dc:creator>
      <dc:date>2016-11-01T20:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202155#M58616</link>
      <description>&lt;P&gt;You could just append a stats count search to your current search. Its not as efficient as the above suggestions but might work as a quick fix if the above is too complicated. A little frustrating that you have to do the same search twice though ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_base_search | table field1, field2 | append [ your_base_search | stats count | eval field1="TOTAL EVENTS" | rename count AS field2 ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;An alternative would be to create a count column but then remove it by adding the total count and label to one of your other columns:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_base_search | eval count=1 | addcoltotals labelfield=field1 label="TOTAL EVENTS" | eval field2=if(field1="TOTAL EVENTS",count,field2) | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 23:31:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202155#M58616</guid>
      <dc:creator>lquinn</dc:creator>
      <dc:date>2016-11-01T23:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202156#M58617</link>
      <description>&lt;P&gt;This is Simple XML example, so it does not require you to add additional css/js ot HTML code. You can refer to Splunk 6.x Dashboard Examples app for details. Just edit source of your existing code and place job.resultCount related code in Chart &amp;lt;title&amp;gt; , &amp;lt;search&amp;gt;&amp;lt;progress&amp;gt; and &amp;lt;search&amp;gt;&amp;lt;cancelled&amp;gt;. The &lt;STRONG&gt;progress&lt;/STRONG&gt; event sets the token sourcetype_count (could be any variable name). Cancelled event resets the token and Title section uses the token. (It is not that tough as it seems :))&lt;/P&gt;

&lt;P&gt;PS: Splunk itself uses the same variable for knowing whether Search returned result or not. For example N/A being displayed when search returns not result.&lt;/P&gt;

&lt;P&gt;Other options if you do not want to use job.resultCount would be &lt;/P&gt;

&lt;P&gt;1) Use accum : ... |eval sno=0 | sno=sno+1 | accum sno| ...&lt;/P&gt;

&lt;P&gt;2) Enable Row Number: Edit Panel, Choose Edit Table option and Under General settings set Row Numbers as Yes.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 09:05:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/202156#M58617</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-02T09:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to add final total count of results without adding another column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/512511#M143754</link>
      <description>&lt;P&gt;Excellent. This works like a charm.&amp;nbsp;&lt;BR /&gt;With this solution, we can show the number of returned results outside a XML table.&lt;BR /&gt;Great. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 06:41:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-final-total-count-of-results-without-adding-another/m-p/512511#M143754</guid>
      <dc:creator>Silmarillion197</dc:creator>
      <dc:date>2020-08-05T06:41:25Z</dc:date>
    </item>
  </channel>
</rss>

