<?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: Sum function issues: How to convert monetary number to a number? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411356#M118670</link>
    <description>&lt;P&gt;You can format the results after the stats. So add this after that stats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..above search with stats
| eval TotalRevenue="$".tostring(TotalRevenue,"comma")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 25 May 2018 18:01:12 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-05-25T18:01:12Z</dc:date>
    <item>
      <title>Sum function issues: How to convert monetary number to a number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411353#M118667</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;I'm beginner on Splunk&lt;/P&gt;

&lt;P&gt;I imported my data from a csv file, all the field is correct, I have 4 columns :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;ID (String =&amp;gt; 54BS26D)&lt;/LI&gt;
&lt;LI&gt;Product Title (String =&amp;gt; ABC PRODUCT)&lt;/LI&gt;
&lt;LI&gt;Ordered Revenue (String =&amp;gt; $20,530.42)&lt;/LI&gt;
&lt;LI&gt;Ordered Units(Number =&amp;gt; 256)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I had two issues :&lt;/P&gt;

&lt;P&gt;1) I would like to do a sum of the revenue and i don't know how to do it because for Splunk the field "Revenue" is a string.&lt;BR /&gt;
2) When i do the sum to find how many pieces i sold with [sourcetype="csv" | stats sum("Ordered Units")], i don't find the same result on excel, i don't know why.&lt;/P&gt;

&lt;P&gt;Could you help please.&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 16:22:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411353#M118667</guid>
      <dc:creator>jelmalem</dc:creator>
      <dc:date>2018-05-25T16:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sum function issues: How to convert monetary number to a number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411354#M118668</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search with fields ID, "Product Title" "Ordered Revenue" and "Ordered Units"
| eval  "Ordered Revenue"=tonumber(replace('Ordered Revenue',"\$|,",""))
| stats sum("Ordered Revenue") as TotalRevenue sum("Ordered Units") as TotalUnitsOrdered by ID "Product Title"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 May 2018 16:44:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411354#M118668</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-25T16:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sum function issues: How to convert monetary number to a number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411355#M118669</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thanks for your quick answer ! It works but : &lt;/P&gt;

&lt;P&gt;In order to get just the Total Ordered Revenue in my dashboard I did [eval  "Ordered Units"=tonumber(replace('Ordered Units',"\$|,","")) | stats sum("Ordered Units")] i get the good number but without the decimal and the $, how I can do it ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 17:19:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411355#M118669</guid>
      <dc:creator>jelmalem</dc:creator>
      <dc:date>2018-05-25T17:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sum function issues: How to convert monetary number to a number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411356#M118670</link>
      <description>&lt;P&gt;You can format the results after the stats. So add this after that stats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..above search with stats
| eval TotalRevenue="$".tostring(TotalRevenue,"comma")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 May 2018 18:01:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411356#M118670</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-25T18:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sum function issues: How to convert monetary number to a number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411357#M118671</link>
      <description>&lt;P&gt;Thanks again, there was a mistake it's eval TotalRevenue="$".tostring(TotalRevenue,"commas").&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 18:58:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411357#M118671</guid>
      <dc:creator>jelmalem</dc:creator>
      <dc:date>2018-05-25T18:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sum function issues: How to convert monetary number to a number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411358#M118672</link>
      <description>&lt;P&gt;So couple of things about displaying formatted &lt;CODE&gt;$&lt;/CODE&gt; amount in table.&lt;/P&gt;

&lt;P&gt;While retaining the dollar amount as number, if you need to show $ and command separator you have following two options:&lt;/P&gt;

&lt;P&gt;1) Use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fieldformat"&gt;fieldformat&lt;/A&gt; instead of eval&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fieldformat TotalRevenue="$".tostring(TotalRevenue,"commas")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) If you are on Splunk 6.5 or higher, you can use Table Formatting option from UI Edit to add commas and Unit before or After the Dollar amount as number.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;format type="number" field="TotalRevenue"&amp;gt;
      &amp;lt;option name="unit"&amp;gt;$&amp;lt;/option&amp;gt;
      &amp;lt;option name="unitPosition"&amp;gt;before&amp;lt;/option&amp;gt;
    &amp;lt;/format&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer to documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/TableFormatsFormatting#Number_format"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Viz/TableFormatsFormatting#Number_format&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 19:42:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sum-function-issues-How-to-convert-monetary-number-to-a-number/m-p/411358#M118672</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-25T19:42:04Z</dc:date>
    </item>
  </channel>
</rss>

