<?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 append a total row for a column chart? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320509#M95794</link>
    <description>&lt;P&gt;This question is so borked that maybe you should start over.  I have NO IDEA what you are trying to do at this point.  The path from your events to your "final iteration" is infinitely cloudy.  I have no ideal what math/logic you are trying to apply.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jul 2017 16:09:48 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-07-20T16:09:48Z</dc:date>
    <item>
      <title>How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320502#M95787</link>
      <description>&lt;P&gt;Hi, so I currently have a column chart that has two bars for each day of the week, one bar is reanalysis and one is resubmission. I want to add a third column for each day that does an average across both items but I can't find a good way to add another field entry.&lt;/P&gt;

&lt;P&gt;I can shape the data to get the Sum/count separately but I'm not sure how to add a total&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Analysis_type        Date        Sum                Count
reanalysis         06/12       50        2  
resubmission         06/12     400      4
reanalysis         06/13       55        5  
resubmission         06/13   500        10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should look like this in final iteration&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    Analysis_type        Date       Average          
    reanalysis         06/12      25
    resubmission         06/12    100   
    Total               06/12      75 ((50 + 400)/(2+4))
    reanalysis         06/13      11
    resubmission         06/13    50
    Total               06/13      37 ((55+500)/(10+5)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if more information is needed to handle this issue.&lt;/P&gt;

&lt;P&gt;Here is the query I am using to generate the first chart.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cumulus_test1 AND (analysis_type="reanalysis" OR analysis_type="resubmission")
| dedup file_name
| eval SizeGB = ubf_size/1000000000 
| eval month_num=strftime(_time,"%m")
| eval day_num=strftime(_time,"%d")
| eval date=month_num."/".day_num
| stats sum(SizeGB) AS Sum, count(file_name) AS count by analysis_type, date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jul 2017 23:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320502#M95787</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-19T23:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320503#M95788</link>
      <description>&lt;P&gt;how did you calculate the averages on the second results?&lt;BR /&gt;
maybe `... | eval Average = round(Sum/Count, 2) &lt;BR /&gt;
hope it helps&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 00:42:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320503#M95788</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-07-20T00:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320504#M95789</link>
      <description>&lt;P&gt;Can you share your query?&lt;/P&gt;

&lt;P&gt;It should look something like &lt;CODE&gt;... | stats values(Date), avg(Average) by Analysis_type&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 00:58:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320504#M95789</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2017-07-20T00:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320505#M95790</link>
      <description>&lt;P&gt;Just add this to the end of your existing search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Average = Sum / Count | fields - Sum Count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320505#M95790</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-20T15:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320506#M95791</link>
      <description>&lt;P&gt;Updated the post with my query&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:40:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320506#M95791</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-20T15:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320507#M95792</link>
      <description>&lt;P&gt;My issue isn't calculating the average but taking an aggregated average of reanalysis and resubmission values and generating another entry for each date under a Total&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:42:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320507#M95792</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-20T15:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320508#M95793</link>
      <description>&lt;P&gt;That gives me the average for both reanalysis and resubmission but I'm trying to get an aggregated average across both. I updated the post with a bit more detail&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:43:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320508#M95793</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-20T15:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320509#M95794</link>
      <description>&lt;P&gt;This question is so borked that maybe you should start over.  I have NO IDEA what you are trying to do at this point.  The path from your events to your "final iteration" is infinitely cloudy.  I have no ideal what math/logic you are trying to apply.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 16:09:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320509#M95794</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-20T16:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320510#M95795</link>
      <description>&lt;P&gt;There's no need to be so snarky considering this is a place where people ask for help...&lt;/P&gt;

&lt;P&gt;Here's the event flow:&lt;BR /&gt;
I have single events that have a ubf_size and one of two different analysis types. I want an average by analysis types and I also want an aggregated average across both analysis types for each day. I'm not sure what's unclear about that. I simplified it so you can see exactly what I mean, right now I have the first two rows but I want to produce a third total row that sums up the Sum(ubf_size) and count(files) from reanalysis and resubmission in order to produce an aggregated average while retaining the data regarding reanalysis and resubmission.&lt;/P&gt;

&lt;P&gt;The data looks like this&lt;BR /&gt;
Analysis Type   Date  Sum(ubf_size)  count(files)  Average&lt;BR /&gt;
reanalysis             06/12              10                   5           2&lt;BR /&gt;
resubmission        06/12             12                   3           4&lt;/P&gt;

&lt;P&gt;I want to add a row like this&lt;BR /&gt;
total       06/12             22                  8           2.75&lt;BR /&gt;
The answer you gave me gives me an average for both reanalysis and resubmission but there is no "total" &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320510#M95795</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2020-09-29T14:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320511#M95796</link>
      <description>&lt;P&gt;Without reading too much, have you tried putting &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | addcoltotals 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At the end?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:15:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320511#M95796</guid>
      <dc:creator>JDukeSplunk</dc:creator>
      <dc:date>2017-07-20T17:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320512#M95797</link>
      <description>&lt;P&gt;can you please elaborate a little more?&lt;BR /&gt;
sorry i cant understand exactly what you are looking for but  in your example, the math does not work considering average = sum / count, your results do not reflect that.&lt;BR /&gt;
maybe you refer to the | addcoltotal command?&lt;BR /&gt;
it is tricky when adding averages, or do you want to add averages?&lt;BR /&gt;
please share some more info so we can better assist&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320512#M95797</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-07-20T17:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320513#M95798</link>
      <description>&lt;P&gt;I attempted that however that gives me the totals across the entire date range when I want the totals to be done by date.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320513#M95798</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-20T17:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320514#M95799</link>
      <description>&lt;P&gt;Try like this&lt;BR /&gt;
** (Updated per comment)**&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cumulus_test1 AND (analysis_type="reanalysis" OR analysis_type="resubmission")
 | dedup file_name
 | eval SizeGB = ubf_size/1000000000 
 | eval month_num=strftime(_time,"%m")
 | eval day_num=strftime(_time,"%d")
 | eval date=month_num."/".day_num
 | stats sum(SizeGB) AS Sum, count(file_name) AS count by analysis_type, date    
| appendpipe [| stats sum(Sum) as Sum sum(count) count by date | eval analysis_type="Total" ]
| eval Average=Sum/count | fields - Sum count
| sort 0 analysis_type date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:22:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320514#M95799</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-20T17:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320515#M95800</link>
      <description>&lt;P&gt;Sorry, I was unclear and used filler numbers to get the point across. I've fixed it so the numbers all make sense&lt;/P&gt;

&lt;P&gt;Each day I produce files with a ubf_size. These files fall into two categories reanalysis and resubmission. I want an average of the ubf_sizes for each category on a per day basis. I also want an aggregated average that combines the two categories. &lt;/P&gt;

&lt;P&gt;Taking the example from 06/12 above&lt;BR /&gt;
Reanalysis had 2 files for a total ubf_size of 50 GB giving an average of 25&lt;BR /&gt;
Resubmission had 4 files for a total ubf_size of 400 GB giving an average of 100&lt;/P&gt;

&lt;P&gt;I have no trouble getting the above two rows but I want to somehow append another row that would look like&lt;BR /&gt;
Total 6 files for a total ubf_size of 450 giving an average of 75.&lt;BR /&gt;
While retaining the data for reanalysis and resubmission and doing it on a per day basis.&lt;/P&gt;

&lt;P&gt;| addcoltotal doesn't work because it does it across the entire dataset when I want the totals per day. I don't want to add averages because that number would be incorrect which is why I calculated the Sum/Count separately to manually calculate the averages instead of using stats avg(ubf_size). I'm simply unsure how to manipulate the Sum/Count to get a separate total.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:59:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320515#M95800</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2020-09-29T14:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320516#M95801</link>
      <description>&lt;P&gt;add to your search:&lt;BR /&gt;
sum(ubf_size) as total_gb count as total_count &lt;BR /&gt;
| eval avg = total_gb / total_count&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:59:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320516#M95801</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2020-09-29T14:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320517#M95802</link>
      <description>&lt;P&gt;See my response to Adonio. I fixed up the numbers in the example to make sense.&lt;/P&gt;

&lt;P&gt;As it is currently, I can generate the averages for both reanalysis and resubmission just fine. If that was it I could use stats avg(ubf_size) to achieve that.&lt;/P&gt;

&lt;P&gt;The issue is that I want an aggregated average which combines the totals of both on a per day basis while retaining the reanalysis and resubmission statistics. To me the best method seems to be calculating the Sum/Count separately then somehow appending the summation on a per day basis to a new analysis_type called "Total" where the &lt;/P&gt;

&lt;P&gt;average=Sum(reanalysis+resubmission ubf_size)/Count(reanalysis+resubmission file count).&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:38:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320517#M95802</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-20T17:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320518#M95803</link>
      <description>&lt;P&gt;Yes, that would successfully give me the total I am looking for but then I lose the statistics regarding reanalysis/resubmission. My final goal is a column chart where the x-axis is the date, y-axis is the average and each date has three columns (reanalysis, resubmission, total).&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:41:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320518#M95803</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-20T17:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to append a total row for a column chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320519#M95804</link>
      <description>&lt;P&gt;Thanks! That worked perfectly!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 17:45:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-append-a-total-row-for-a-column-chart/m-p/320519#M95804</guid>
      <dc:creator>byu168168</dc:creator>
      <dc:date>2017-07-20T17:45:31Z</dc:date>
    </item>
  </channel>
</rss>

