<?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 How do you make a division with 2 numbers from the same field filtered by a condition from another field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439094#M124932</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;I need to make a division with 2 numbers from the same field, but they are filtered from another field.&lt;BR /&gt;
Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1  i have :  "Accepted", "Not Accepted", "TOTAL"
field2 i have in the same order: 100, 200, 500
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The sum (Accepted + Not Accepted) is not necessarily the TOTAL. There may be reprocessed records that enter the total.   &lt;/P&gt;

&lt;P&gt;The records/events are so confused because they are coming from a database query.&lt;/P&gt;

&lt;P&gt;I need to get the percentage of the Number of  "Not Accepted"  over the grand total(TOTAL), and the same to "Accepted".&lt;/P&gt;

&lt;P&gt;Anyone have a good idea?&lt;/P&gt;

&lt;P&gt;Ty.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2018 17:18:07 GMT</pubDate>
    <dc:creator>lucasfbeinjamin</dc:creator>
    <dc:date>2018-10-19T17:18:07Z</dc:date>
    <item>
      <title>How do you make a division with 2 numbers from the same field filtered by a condition from another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439094#M124932</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;I need to make a division with 2 numbers from the same field, but they are filtered from another field.&lt;BR /&gt;
Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1  i have :  "Accepted", "Not Accepted", "TOTAL"
field2 i have in the same order: 100, 200, 500
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The sum (Accepted + Not Accepted) is not necessarily the TOTAL. There may be reprocessed records that enter the total.   &lt;/P&gt;

&lt;P&gt;The records/events are so confused because they are coming from a database query.&lt;/P&gt;

&lt;P&gt;I need to get the percentage of the Number of  "Not Accepted"  over the grand total(TOTAL), and the same to "Accepted".&lt;/P&gt;

&lt;P&gt;Anyone have a good idea?&lt;/P&gt;

&lt;P&gt;Ty.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 17:18:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439094#M124932</guid>
      <dc:creator>lucasfbeinjamin</dc:creator>
      <dc:date>2018-10-19T17:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a division with 2 numbers from the same field filtered by a condition from another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439095#M124933</link>
      <description>&lt;P&gt;If the order in your field2 is always going to be as Accepted, Not accepted, Total then you can extract the numbers and do calculation&lt;BR /&gt;
as below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;yourindex&amp;gt;| | rex field=field2 "(?&amp;lt;Accepted_count&amp;gt;\d+),\d+,\d+"|rex field=field2 "\d+,(?&amp;lt;UnAccepted_count&amp;gt;\d+),\d+"|rex field=field2 "\d+,\d+,(?&amp;lt;Total_count&amp;gt;\d+)"| eval Accept_per=Accepted_count/Total_count * 100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Oct 2018 17:33:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439095#M124933</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-19T17:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a division with 2 numbers from the same field filtered by a condition from another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439096#M124934</link>
      <description>&lt;P&gt;Hi @Vijeta&lt;/P&gt;

&lt;P&gt;I think you misunderstood how the events listed, the fields are already regex of an event, I put them that way, but actually they are in columns in my Statistics tab, you see?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 18:23:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439096#M124934</guid>
      <dc:creator>lucasfbeinjamin</dc:creator>
      <dc:date>2018-10-19T18:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a division with 2 numbers from the same field filtered by a condition from another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439097#M124935</link>
      <description>&lt;P&gt;My bad...you mean it is like this?&lt;/P&gt;

&lt;P&gt;field1               field2&lt;/P&gt;

&lt;P&gt;Accepted              100&lt;BR /&gt;
Not Accepted        200&lt;BR /&gt;
Total                     500&lt;/P&gt;

&lt;P&gt;In that case you can use below logic and calculate percentage&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;&amp;gt;| eval A=if(field1="Accepted",field2)| eval NA=if(field1="Not Accepted",field2)| eval Tot=if(field1="Total",field2)| stats sum(A) as A, sum(NA) as NA, sum(Tot) as Tot
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Oct 2018 18:35:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439097#M124935</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-19T18:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a division with 2 numbers from the same field filtered by a condition from another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439098#M124936</link>
      <description>&lt;P&gt;Does this makes sense-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eventstats max(field2) as total|eval percentage=((field2/total)*100)."%"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;below is sample run anywhere search-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval field1="Accepted", field2=100| append [| makeresults |eval field1="Not Accepted", field2=200]| append [| makeresults |eval field1="TOTAL", field2=500]|eventstats max(field2) as total|eval percentage=((field2/total)*100)."%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Oct 2018 18:36:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439098#M124936</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-10-19T18:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a division with 2 numbers from the same field filtered by a condition from another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439099#M124937</link>
      <description>&lt;P&gt;Thankyou, you helped me a lot!!!!&lt;/P&gt;

&lt;H1&gt;GoSplunk&lt;/H1&gt;</description>
      <pubDate>Fri, 19 Oct 2018 19:30:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439099#M124937</guid>
      <dc:creator>lucasfbeinjamin</dc:creator>
      <dc:date>2018-10-19T19:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a division with 2 numbers from the same field filtered by a condition from another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439100#M124938</link>
      <description>&lt;P&gt;Thank you for wasting your time trying to help me! I'm very grateful for that!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 19:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-division-with-2-numbers-from-the-same-field/m-p/439100#M124938</guid>
      <dc:creator>lucasfbeinjamin</dc:creator>
      <dc:date>2018-10-19T19:31:52Z</dc:date>
    </item>
  </channel>
</rss>

