<?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 show stats sum for a field using a value produced from an eval statement? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278623#M84127</link>
    <description>&lt;P&gt;| stats count by mnd&lt;/P&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;P&gt;| stats count by sum(mnd)&lt;/P&gt;</description>
    <pubDate>Thu, 11 Feb 2016 09:57:56 GMT</pubDate>
    <dc:creator>sunnyparmar</dc:creator>
    <dc:date>2016-02-11T09:57:56Z</dc:date>
    <item>
      <title>How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278619#M84123</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have one field with values for each month, and this eval gives me the current month name(current February);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval mnd=strftime(_time, "%B")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Field1 is named January, Field2 February...&lt;/P&gt;

&lt;P&gt;But when I try to sum this field with stats, I get no results;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;stats sum(mnd)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want this search to automatically show the current month's sum, and not using a static value in the stats sum expression.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 21:13:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278619#M84123</guid>
      <dc:creator>franksteinar</dc:creator>
      <dc:date>2016-02-10T21:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278620#M84124</link>
      <description>&lt;P&gt;Hi, sorry I'm a bit confused by your question.&lt;BR /&gt;
%B is creating a string therefore you can't sum it in Splunk.&lt;/P&gt;

&lt;P&gt;If you want to sum months using integers simply use %m instead.&lt;/P&gt;

&lt;P&gt;Stats won't care about whether your field comes from an eval or not. A field is a field.&lt;/P&gt;

&lt;P&gt;Please let me know if that's not what you are looking for.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 21:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278620#M84124</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-10T21:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278621#M84125</link>
      <description>&lt;P&gt;Are you looking for a sum of some field and you want column (with sum) for each month?? If that's the case try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | eval mnd=strftime(_time, "%B")  | eval temp=1 | chart sum(WhateverFieldYouWantToSum) over temp by mnd | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Feb 2016 22:05:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278621#M84125</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-10T22:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278622#M84126</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;sorry, I will try to be more presise. What I want to accomplish, is to present a dashboard showing the sum of values from the month we are currently in. For now, that is February, and even though I easily can display February with a static expression;&lt;BR /&gt;
stats sum(February)&lt;/P&gt;

&lt;P&gt;that means I need to maintain this manually every month to match the month we are currently in. How can I make this flexible, so that the stats sum choose the current month. Each month is represented with its own field(or column).&lt;/P&gt;

&lt;P&gt;Hope this makes more sense:) &lt;/P&gt;

&lt;P&gt;PS! Using %m did not make any difference, even though I adjusted the fields/columns to 01, 02,  03...&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 09:27:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278622#M84126</guid>
      <dc:creator>franksteinar</dc:creator>
      <dc:date>2016-02-11T09:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278623#M84127</link>
      <description>&lt;P&gt;| stats count by mnd&lt;/P&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;P&gt;| stats count by sum(mnd)&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 09:57:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278623#M84127</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2016-02-11T09:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278624#M84128</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;the challenge here is that "WhateverFieldYouWantToSum" is a static reference to a field, I need a dynamic reference to a field.&lt;BR /&gt;
From my last post:&lt;BR /&gt;
What I want to accomplish, is to present a dashboard showing the sum of values from the month we are currently in. For now, that is February, and even though I easily can display February with a static expression;&lt;BR /&gt;
stats sum(February)&lt;/P&gt;

&lt;P&gt;that means I need to maintain this manually every month to match the month we are currently in. How can I make this flexible, so that the stats sum choose the current month. Each month is represented with its own field(or column).&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 10:24:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278624#M84128</guid>
      <dc:creator>franksteinar</dc:creator>
      <dc:date>2016-02-11T10:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278625#M84129</link>
      <description>&lt;P&gt;Here the month name (which will appear as a column name) is dynamic only. Not sure if you tried this at all.. &lt;/P&gt;

&lt;P&gt;Could you provide the current search where you've to provide the Month name using static expression??&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 15:47:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278625#M84129</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-11T15:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278626#M84130</link>
      <description>&lt;P&gt;If you want to display the current monthly dynamically simply use the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval current_month = strftime(now(), "%B")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then restrict your search to only return events for the month we are currently in:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar earliest=@mon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope that makes sense.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 10:12:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278626#M84130</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-12T10:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to show stats sum for a field using a value produced from an eval statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278627#M84131</link>
      <description>&lt;P&gt;The first one is right.  The second doesn't seem to make any sense.  &lt;/P&gt;

&lt;P&gt;I think you may have meant (for the second one)&lt;/P&gt;

&lt;P&gt;| stats sum(SomeField) as "Total of SomeField" by mnd&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 23:04:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-show-stats-sum-for-a-field-using-a-value-produced-from-an/m-p/278627#M84131</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-05T23:04:23Z</dc:date>
    </item>
  </channel>
</rss>

