<?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 sum correctly? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324267#M96767</link>
    <description>&lt;P&gt;Hello eliotproebstel,&lt;/P&gt;

&lt;P&gt;When I do the command values(DomesticAmount), it gives me all the values that need to be added. But once I run the command sum(DomesticAmount), it gives me a completely different answer than what I know should be. On one of the occasions, a warning showed up stating that some values may have been truncated or ignored. The sum is of of 8 digits, but the values are not larger than 5 digits. Would this be an issue? &lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2017 20:55:56 GMT</pubDate>
    <dc:creator>tonahoyos</dc:creator>
    <dc:date>2017-10-25T20:55:56Z</dc:date>
    <item>
      <title>How to sum correctly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324265#M96765</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I am having an issue using the stats sum command. This is currently my search:&lt;/P&gt;

&lt;P&gt;source="Jan_Sept_FinanceSample.csv" host="Jan_September" index="finance_sample" sourcetype="csv" ObjectAccount="411010" OR ObjectAccount="5*"&lt;BR /&gt;
| eval Sales=if(ObjectAccount="411010",DomesticAmount,0), Costs=if(like(ObjectAccount,"5%"),DomesticAmount,0)&lt;BR /&gt;
| stats sum(Sales) as Sales , sum(Costs) as Costs &lt;/P&gt;

&lt;P&gt;I checked if the values were correctly summed on excel, and it turns out that the sums are off. What can it be? I tried to erase and upload the data again, I tried to reformat the values, etc. Is this the wrong command to use? &lt;/P&gt;

&lt;P&gt;There are positive and negative values on the Domestic Amount field, I am not sure if it is taking all of the negative values. &lt;/P&gt;

&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:24:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324265#M96765</guid>
      <dc:creator>tonahoyos</dc:creator>
      <dc:date>2020-09-29T16:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum correctly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324266#M96766</link>
      <description>&lt;P&gt;Have you checked to make sure the values populating the &lt;CODE&gt;Sales&lt;/CODE&gt; and &lt;CODE&gt;Costs&lt;/CODE&gt; fields match what you expect? Maybe try this to be sure:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;source="Jan_Sept_FinanceSample.csv" host="Jan_September" index="finance_sample" sourcetype="csv" ObjectAccount="411010" OR ObjectAccount="5*"&lt;BR /&gt;
| eval Sales=if(ObjectAccount="411010",DomesticAmount,0), Costs=if(like(ObjectAccount,"5%"),DomesticAmount,0)&lt;BR /&gt;
| stats list(Sales) as Sales , list(Costs) as Costs BY ObjectAccount&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If that's not the issue, are the values you are summing particularly large? Negative values alone should not cause this problem.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 21:06:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324266#M96766</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T21:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum correctly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324267#M96767</link>
      <description>&lt;P&gt;Hello eliotproebstel,&lt;/P&gt;

&lt;P&gt;When I do the command values(DomesticAmount), it gives me all the values that need to be added. But once I run the command sum(DomesticAmount), it gives me a completely different answer than what I know should be. On one of the occasions, a warning showed up stating that some values may have been truncated or ignored. The sum is of of 8 digits, but the values are not larger than 5 digits. Would this be an issue? &lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 20:55:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324267#M96767</guid>
      <dc:creator>tonahoyos</dc:creator>
      <dc:date>2017-10-25T20:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum correctly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324268#M96768</link>
      <description>&lt;P&gt;@tonahoyos, by testing in Excel, do you mean you ran query in Splunk without the final &lt;CODE&gt;stats&lt;/CODE&gt; pipe and exported the result as CSV using &lt;CODE&gt;Export&lt;/CODE&gt; button in Splunk Search UI. And then calculate the sum by opening CSV in Excel?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="Jan_Sept_FinanceSample.csv" host="Jan_September" index="finance_sample" sourcetype="csv" ObjectAccount="411010" OR ObjectAccount="5*"
| eval Sales=if(ObjectAccount="411010",DomesticAmount,0), Costs=if(like(ObjectAccount,"5%"),DomesticAmount,0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 21:16:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324268#M96768</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-25T21:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum correctly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324269#M96769</link>
      <description>&lt;P&gt;First do this and see if the results look reasonable...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="Jan_Sept_FinanceSample.csv" host="Jan_September" index="finance_sample" sourcetype="csv" 
| stats sum(DomesticAmount) as TotalAmount by ObjectAccount
| appendpipe [ | eval ObjectAccount = substr(ObjectAccount ,1,1)." Total" | stats sum(TotalAmount) as TotalAmount  by ObjectAccount ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 21:46:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324269#M96769</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-25T21:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum correctly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324270#M96770</link>
      <description>&lt;P&gt;The results are exactly the same as before. It seems as if some values are being ignored. Thank you for your help! &lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 15:25:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324270#M96770</guid>
      <dc:creator>tonahoyos</dc:creator>
      <dc:date>2017-10-27T15:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum correctly?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324271#M96771</link>
      <description>&lt;P&gt;I double checked my answers with the original excel dataset that I uploaded in Splunk. It seems as if it was not reading some values. &lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 15:27:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-correctly/m-p/324271#M96771</guid>
      <dc:creator>tonahoyos</dc:creator>
      <dc:date>2017-10-27T15:27:30Z</dc:date>
    </item>
  </channel>
</rss>

