<?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 Match day and get the sum by day, also get the percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Match-day-and-get-the-sum-by-day-also-get-the-percentage/m-p/345435#M102345</link>
    <description>&lt;P&gt;My data looks like this, I've grouped it by a common field. I want to match the date_mday and get the sum of the events for that day.&lt;/P&gt;

&lt;P&gt;commonField    list(field1)   list(date_mday)  list(count)&lt;BR /&gt;
abc    f222  efg   20  10&lt;BR /&gt;
abc    f333   ccc   20   20&lt;BR /&gt;
abc    f222  efg   20  30&lt;BR /&gt;
abc    f334   ccc   20   40 -- sum of count for same date_mday - 10 + 20 + 30 + 40 = 100&lt;BR /&gt;
&lt;EM&gt;abc    f114  ddd   19  10&lt;BR /&gt;
abc    f113  ccd   19  9 -&lt;/EM&gt;- sum of count for outliers for same date_mday - 10+9 = 19&lt;/P&gt;

&lt;P&gt;def    f222  efg   22 10&lt;BR /&gt;
def    f333   ccc   22   25 -- sum of count for same date_mday - 10+25+5 = 40&lt;BR /&gt;
def    f111  bbb   22  5&lt;BR /&gt;
&lt;EM&gt;def    f111  bbb   20  15&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;There are some outliers(in italic) in the data. Then, I want to get the percentage of the outlier vs the total sum.&lt;/P&gt;

&lt;P&gt;I'm using the stats command for grouping the data  running over a 30 days range, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; search string here | stats list(field1),list(field2),list(date_mday),list(count) by commonField
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 15:50:26 GMT</pubDate>
    <dc:creator>known_user</dc:creator>
    <dc:date>2020-09-29T15:50:26Z</dc:date>
    <item>
      <title>Match day and get the sum by day, also get the percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-day-and-get-the-sum-by-day-also-get-the-percentage/m-p/345435#M102345</link>
      <description>&lt;P&gt;My data looks like this, I've grouped it by a common field. I want to match the date_mday and get the sum of the events for that day.&lt;/P&gt;

&lt;P&gt;commonField    list(field1)   list(date_mday)  list(count)&lt;BR /&gt;
abc    f222  efg   20  10&lt;BR /&gt;
abc    f333   ccc   20   20&lt;BR /&gt;
abc    f222  efg   20  30&lt;BR /&gt;
abc    f334   ccc   20   40 -- sum of count for same date_mday - 10 + 20 + 30 + 40 = 100&lt;BR /&gt;
&lt;EM&gt;abc    f114  ddd   19  10&lt;BR /&gt;
abc    f113  ccd   19  9 -&lt;/EM&gt;- sum of count for outliers for same date_mday - 10+9 = 19&lt;/P&gt;

&lt;P&gt;def    f222  efg   22 10&lt;BR /&gt;
def    f333   ccc   22   25 -- sum of count for same date_mday - 10+25+5 = 40&lt;BR /&gt;
def    f111  bbb   22  5&lt;BR /&gt;
&lt;EM&gt;def    f111  bbb   20  15&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;There are some outliers(in italic) in the data. Then, I want to get the percentage of the outlier vs the total sum.&lt;/P&gt;

&lt;P&gt;I'm using the stats command for grouping the data  running over a 30 days range, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; search string here | stats list(field1),list(field2),list(date_mday),list(count) by commonField
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-day-and-get-the-sum-by-day-also-get-the-percentage/m-p/345435#M102345</guid>
      <dc:creator>known_user</dc:creator>
      <dc:date>2020-09-29T15:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Match day and get the sum by day, also get the percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-day-and-get-the-sum-by-day-also-get-the-percentage/m-p/345436#M102346</link>
      <description>&lt;P&gt;I'm not sure I understand the methodology you are trying to replicate with "outliers", but let me try a few slightly more general tips and see if those get you what you want.&lt;/P&gt;

&lt;P&gt;First, this might get you a lot closer:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; search string here | stats count, list(field1),list(field2),list(count) by commonField, date_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice I added a "count" to the output side of your stats, and moved date_mday to the group by section.  Now, I'm not sure I'm reading your data right up in the question, but I think your output should be a count per day per common field (with those remaining fields as a list, just like before).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;commonfield, date_mday, list(f1), list(f2), count
abc, 19, efg..., ghi..., 18
abc, 20, efg..., ghi..., 14
xyz, 19, efg..., ghi..., 13
xyz, 20, efg..., ghi..., 15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Again, I'm making up what I think your data looks like.  So for the 20th, you'd have 14+15, the 19th would be 18+13.  Now, to get a total per day, you can use &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Eventstats" target="_blank"&gt;eventstats&lt;/A&gt; on the end of your existing search. Evenstats won't "split it up again" it'll just add stats to the whole pile.    I'm busting up the search into rows to make it easier to read...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search string here 
| stats count, list(field1),list(field2),list(count) by commonField, date_mday
| eventstats count AS Daily_Count BY date_mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this case, eventstats has been told to do a count (and call it "Daily_Count") of the events each &lt;CODE&gt;date_mday&lt;/CODE&gt;.  Your output should now be something like ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;commonfield, date_mday, list(f1), list(f2), count, Daily_Count
abc, 19, efg..., ghi..., 18, 31
abc, 20, efg..., ghi..., 14, 29
xyz, 19, efg..., ghi..., 13, 31
xyz, 20, efg..., ghi..., 15, 29
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hopefully my math's right - all of the events that exist on the 19th will have a &lt;CODE&gt;Daily_Count&lt;/CODE&gt; of 31.  All the events on the 20th will have 29.  &lt;/P&gt;

&lt;P&gt;So, while I'm not sure if this really solves your problem or not, I hope it gives you the tools you need to solve it yourself.  &lt;/P&gt;

&lt;P&gt;If you have further difficulties or if you can provide a simpler, less complex example (or actual real live events!), please comment back!&lt;/P&gt;

&lt;P&gt;(And also, if you DO resolve it yourself with these tools and tips, please paste the answer back here too!)&lt;/P&gt;

&lt;P&gt;Happy Splunking!&lt;BR /&gt;
Rich&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:54:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-day-and-get-the-sum-by-day-also-get-the-percentage/m-p/345436#M102346</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-09-29T15:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Match day and get the sum by day, also get the percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-day-and-get-the-sum-by-day-also-get-the-percentage/m-p/345437#M102347</link>
      <description>&lt;P&gt;Hey @known_user, if @rich7177 solved your problem, please don't forget to accept an answer! You can upvote posts as well. (Karma points will be awarded for either action.) Happy Splunking!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 00:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-day-and-get-the-sum-by-day-also-get-the-percentage/m-p/345437#M102347</guid>
      <dc:creator>lfedak_splunk</dc:creator>
      <dc:date>2017-09-22T00:13:50Z</dc:date>
    </item>
  </channel>
</rss>

