<?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: After grouping by Date how can I SUM against a column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/After-grouping-by-Date-how-can-I-SUM-against-a-column/m-p/203285#M187615</link>
    <description>&lt;P&gt;After running stats, all fields other than your group by field or your calculations are gone. So you cannot eval any other values out of them at that point, and that's why running eval with &lt;CODE&gt;_time&lt;/CODE&gt; as an input was failing.&lt;/P&gt;

&lt;P&gt;Might I suggest other commands? such as &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/timechart"&gt;timechart&lt;/A&gt; where you would keep _time as an epoch value making rolling up later easier... Assuming you only want monthly totals:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security sourcetype=WeatherUnderground | timechart span=1d latest("current_observation.precip_today_in") as DailyRainfall | timechart span=1mon sum(DailyRainfall) as MonthlyTotal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;your fields after this would be &lt;CODE&gt;_time&lt;/CODE&gt; (epoch time locked to the month) and &lt;CODE&gt;MonthlyTotal&lt;/CODE&gt; ... and you can eval and format to your hearts content after this point&lt;/P&gt;

&lt;P&gt;Alternatively, if you wanted both Daily Rainfall, and Monthly totals you could use &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/appendpipe"&gt;appendpipe&lt;/A&gt; to get both sets of data in one search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security sourcetype=WeatherUnderground | timechart span=1d latest("current_observation.precip_today_in") as DailyRainfall | appendpipe [timechart span=1mon sum(DailyRainfall) as MonthlyTotal]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you may wind up doing some sorting on _time afterwards ... but if you were guaranteeing that your timescale was within the month, then you may actually only want to use &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/addtotals"&gt;addtotals&lt;/A&gt; or &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/addcoltotals"&gt;addcoltotals&lt;/A&gt;. But that's likely not the format you're looking for.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jun 2016 23:15:50 GMT</pubDate>
    <dc:creator>acharlieh</dc:creator>
    <dc:date>2016-06-10T23:15:50Z</dc:date>
    <item>
      <title>After grouping by Date how can I SUM against a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/After-grouping-by-Date-how-can-I-SUM-against-a-column/m-p/203284#M187614</link>
      <description>&lt;P&gt;I am running the following query&lt;/P&gt;

&lt;P&gt;index=security sourcetype=WeatherUnderground  | eval Date=strftime(_time,"%m/%d/%y") |stats latest("current_observation.precip_today_in") as DailyRainfall by Date |  table  Date, DailyRainfall&lt;/P&gt;

&lt;P&gt;And it produces data as it is supposed to, showing me the daily totals of rainfall.  I want to ultimately create a table that is the SUM of the daily rainfall for each day in the month and then display it as a MonthYear , MonthlyTotal.&lt;/P&gt;

&lt;P&gt;I have tried using the bin command to group by month after the stats and I have also tried to extract the month after I run the above query with a pipe to eval MonthYear=strftime(_time,"%B %Y")  but the data doesn't show up.  How can I turn this data into a table of monthYear , monthlyTotals?  Attached is the current query and results.  Thank you.&lt;IMG src="https://community.splunk.com/storage/temp/137211-rainfallquery.jpg" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:54:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/After-grouping-by-Date-how-can-I-SUM-against-a-column/m-p/203284#M187614</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2020-09-29T09:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: After grouping by Date how can I SUM against a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/After-grouping-by-Date-how-can-I-SUM-against-a-column/m-p/203285#M187615</link>
      <description>&lt;P&gt;After running stats, all fields other than your group by field or your calculations are gone. So you cannot eval any other values out of them at that point, and that's why running eval with &lt;CODE&gt;_time&lt;/CODE&gt; as an input was failing.&lt;/P&gt;

&lt;P&gt;Might I suggest other commands? such as &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/timechart"&gt;timechart&lt;/A&gt; where you would keep _time as an epoch value making rolling up later easier... Assuming you only want monthly totals:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security sourcetype=WeatherUnderground | timechart span=1d latest("current_observation.precip_today_in") as DailyRainfall | timechart span=1mon sum(DailyRainfall) as MonthlyTotal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;your fields after this would be &lt;CODE&gt;_time&lt;/CODE&gt; (epoch time locked to the month) and &lt;CODE&gt;MonthlyTotal&lt;/CODE&gt; ... and you can eval and format to your hearts content after this point&lt;/P&gt;

&lt;P&gt;Alternatively, if you wanted both Daily Rainfall, and Monthly totals you could use &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/appendpipe"&gt;appendpipe&lt;/A&gt; to get both sets of data in one search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security sourcetype=WeatherUnderground | timechart span=1d latest("current_observation.precip_today_in") as DailyRainfall | appendpipe [timechart span=1mon sum(DailyRainfall) as MonthlyTotal]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you may wind up doing some sorting on _time afterwards ... but if you were guaranteeing that your timescale was within the month, then you may actually only want to use &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/addtotals"&gt;addtotals&lt;/A&gt; or &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/addcoltotals"&gt;addcoltotals&lt;/A&gt;. But that's likely not the format you're looking for.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 23:15:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/After-grouping-by-Date-how-can-I-SUM-against-a-column/m-p/203285#M187615</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2016-06-10T23:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: After grouping by Date how can I SUM against a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/After-grouping-by-Date-how-can-I-SUM-against-a-column/m-p/203286#M187616</link>
      <description>&lt;P&gt;Thank you very much.  I didn't realize my other fields were lost after stats.  Timechart works great .  And I have been able to combine it with my other data (which comes from temp sensors around the house and build the following chart now)&lt;/P&gt;

&lt;P&gt;Monthly Statistics&lt;BR /&gt;
Month       Max Temp    Min Temp    Monthly Range   Monthly Rainfall&lt;BR /&gt;
June 2016   90.5        52.5        38.0        0.09&lt;BR /&gt;
May 2016    83.6        25.7        57.9&lt;BR /&gt;&lt;BR /&gt;
April 2016  79.1        27.7        51.4     &lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 23:31:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/After-grouping-by-Date-how-can-I-SUM-against-a-column/m-p/203286#M187616</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2016-06-10T23:31:27Z</dc:date>
    </item>
  </channel>
</rss>

