<?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 multiply a field count by the field value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441099#M125339</link>
    <description>&lt;P&gt;Can you post some sample raw data? I'm guessing field Batch_Size is not recognized as number (per your field extraction, you're extracting a space as well in its value) and the multiplication is failing. Give this a try as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"\(TOTAL_REC\)::"
     |rex field=_raw "(\(TOTAL_REC\)::)\s(?P&amp;lt;Batch_Size&amp;gt;\d)"
     |stats count  by Batch_Size
     | eval tc = Batch_Size*count
     | stats sum(tc) as tc
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Aug 2019 13:48:59 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2019-08-13T13:48:59Z</dc:date>
    <item>
      <title>How to multiply a field count by the field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441094#M125334</link>
      <description>&lt;P&gt;We have a field whose values change called received_files. The values could be any integer. I need to take these values and multiply that integer by the count of the value.&lt;/P&gt;

&lt;P&gt;This is best explained by an example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;received_files has the following field values: 1, 2, and 3. There are 100 results for "received_files=1", 50 results for "received_files=2", and 10 results for "received_files=3".
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Based on this, I want to do this calculation: (1*100)+(2*50)+(3*10)=210. Then I want to put that 210 into a field called "total_files_received". The value of received_files changes all the time and could have 1, 2, and 3 one second, then it could have 350 in there the next.&lt;/P&gt;

&lt;P&gt;How do I do this?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:27:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441094#M125334</guid>
      <dc:creator>ryan_t_gavin</dc:creator>
      <dc:date>2020-09-29T20:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply a field count by the field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441095#M125335</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search fetching field received_files
|stats count by received_files
| eval total_files_received=received_files*count
| stats sum(total_files_received) as total_files_received
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 16:20:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441095#M125335</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-17T16:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply a field count by the field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441096#M125336</link>
      <description>&lt;P&gt;I did NOT know you could just multiply it by "count". I've always used it as you did in stats, or by using count(). Thanks! That did exactly what I wanted.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 18:01:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441096#M125336</guid>
      <dc:creator>ryan_t_gavin</dc:creator>
      <dc:date>2018-07-17T18:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply a field count by the field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441097#M125337</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;Can someone please help me with this query? I am trying to multiply the fields Batch_Size and count and return the results in the tc field. I tried the above syntax but it did not work. &lt;/P&gt;

&lt;P&gt;The first three lines of this query work fine by itself. After adding the lines 4,5, it does not return anything. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    "\(TOTAL_REC\)::"
    |rex field=_raw "(\(TOTAL_REC\)::)(?P&amp;lt;Batch_Size&amp;gt;\s(\d))"
    |stats count  by Batch_Size
    | eval tc = Batch_Size*count
    | stats sum(tc) as tc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Multiplying "count" by a whole number returns expected result with three columns. When i replace 10 with Batch_Size, it gives only two columns : Batch_Size, count.&lt;/P&gt;

&lt;P&gt;Not sure why Batch_Size is not working in the multiplication operation.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"\(TOTAL_REC\)::" 
 |rex field=_raw "(\(TOTAL_REC\)::)(?P&amp;lt;Batch_Size&amp;gt;\s(\d))" 
 | convert num(Batch_Size) 
 | stats count BY Batch_Size
 | eval tc = (10 * count)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Splunk Enterprise Version: 7.2.6&lt;/P&gt;

&lt;P&gt;Any help will be appreciated. Thanks, Ro&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:45:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441097#M125337</guid>
      <dc:creator>rlaul</dc:creator>
      <dc:date>2020-09-30T01:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply a field count by the field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441098#M125338</link>
      <description>&lt;P&gt;It did not work for me &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; . Please see my comment above.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 12:59:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441098#M125338</guid>
      <dc:creator>rlaul</dc:creator>
      <dc:date>2019-08-13T12:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply a field count by the field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441099#M125339</link>
      <description>&lt;P&gt;Can you post some sample raw data? I'm guessing field Batch_Size is not recognized as number (per your field extraction, you're extracting a space as well in its value) and the multiplication is failing. Give this a try as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"\(TOTAL_REC\)::"
     |rex field=_raw "(\(TOTAL_REC\)::)\s(?P&amp;lt;Batch_Size&amp;gt;\d)"
     |stats count  by Batch_Size
     | eval tc = Batch_Size*count
     | stats sum(tc) as tc
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Aug 2019 13:48:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441099#M125339</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-08-13T13:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply a field count by the field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441100#M125340</link>
      <description>&lt;P&gt;Thank you somesoni2. That worked. I really appreciate your help. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 15:29:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-multiply-a-field-count-by-the-field-value/m-p/441100#M125340</guid>
      <dc:creator>rlaul</dc:creator>
      <dc:date>2019-08-23T15:29:19Z</dc:date>
    </item>
  </channel>
</rss>

