<?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: Calculate percentage between 2 reports in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416301#M168551</link>
    <description>&lt;P&gt;hello niletnilnay&lt;/P&gt;

&lt;P&gt;It will be almost perfect but there is a misunderstoog&lt;BR /&gt;
the percentage has to be calculated not between mfetp and mcshield but between mfetp and meftp or between mcshield and mcshield&lt;BR /&gt;
i m explaining : i want to compare between 2 machines (host) the percentage of disk and memory used for a specifique service (mfetp or mcshield)&lt;BR /&gt;
do you understand what i mean?&lt;BR /&gt;
is it possible to adapt the code please?&lt;BR /&gt;
i need also something else : if the result of the percentage is negative (value of first mfetp field &amp;gt; value of second mfetp field) i want for example to display +5% and if the result of the percentage is positive (value of first mfetp field &amp;lt; value of second mfetp field) i want to display -5%&lt;BR /&gt;
could you help me please???&lt;BR /&gt;
many thanks&lt;/P&gt;</description>
    <pubDate>Mon, 02 Jul 2018 18:34:49 GMT</pubDate>
    <dc:creator>jip31</dc:creator>
    <dc:date>2018-07-02T18:34:49Z</dc:date>
    <item>
      <title>Calculate percentage between 2 reports</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416298#M168548</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I use 2 reports with the code below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="windows-wmi" sourcetype="wmi:DiskRAMLoad" host="$field1$" (Name="mfetp.exe" OR Name="mcshield.exe") Name=$Service$ | head 10 | table _time Name host Name ReadOperationCount ReadTransferCount WriteOperationCount  WriteTransferCount | eval _time = strftime(_time, "%Y-%m-%d %H:%M") | stats values(Name) as Name, avg(ReadOperationCount), avg(ReadTransferCount), avg(WriteOperationCount), avg(WriteTransferCount) BY host | rename avg(ReadOperationCount) as ReadOperation_AVG, avg(ReadTransferCount) as ReadTransfer_AVG, avg(WriteOperationCount) as WriteOperation_AVG, avg(WriteTransferCount) as WriteTransfer_AVG
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;On the first report, i get the value corresponding to Name="mfetp.exe"  and on the second, i get the value corresponding to Name="mcshield.exe") &lt;BR /&gt;
With the values of the 2 reports, i have to calculate the percentage between the values&lt;BR /&gt;
example : i want to obtain the percentage between avg(ReadOperationCount) from the first report and avg(ReadOperationCount) from the second report&lt;BR /&gt;
have you any idea how to do please??&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 17:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416298#M168548</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2018-07-02T17:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between 2 reports</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416299#M168549</link>
      <description>&lt;P&gt;@jip31, a lot of cleanup seems to be required in your code. Can you please try the following search first?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="windows-wmi" sourcetype="wmi:DiskRAMLoad" host="$field1$" Name="mfetp.exe" 
| head 10 
| stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG, avg(WriteOperationCount) as mfetp_WriteOperation_AVG, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG 
| appendcols 
    [ search index="windows-wmi" sourcetype="wmi:DiskRAMLoad" host="$field1$" Name="mcshield.exe" 
    | head 10 
    | stats avg(ReadOperationCount) as mcshield_ReadOperation_AVG, avg(ReadTransferCount) as mcshield_ReadTransfer_AVG, avg(WriteOperationCount) as mcshield_WriteOperation_AVG, avg(WriteTransferCount) as mcshield_WriteTransfer_AVG] 
| eval percReadOperation_AVG=round((mfetp_ReadOperation_AVG/mcshield_ReadOperation_AVG)*100,2),
    percReadTransfer_AVG=round((mfetp_ReadTransfer_AVG/mcshield_ReadTransfer_AVG)*100,2),
    percWriteOperation_AVG=round((mfetp_WriteOperation_AVG/mcshield_WriteOperation_AVG)*100,2),
    percWriteTransfer_AVG=round((mfetp_WriteTransfer_AVG/mcshield_WriteTransfer_AVG)*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: I have used &lt;CODE&gt;ratio*100&lt;/CODE&gt; for percent. However, you can use your own formula.&lt;BR /&gt;
Also since you are using tokens like &lt;CODE&gt;host="$field1$"&lt;/CODE&gt;, is it fair to assume that your reports for &lt;CODE&gt;mfetp.exe&lt;/CODE&gt; and &lt;CODE&gt;mcshield.exe&lt;/CODE&gt; are actually dashboard panels? If they are then besides &lt;CODE&gt;appendcols&lt;/CODE&gt; you have another option to use search event handler. For example you can code the &lt;CODE&gt;&amp;lt;done&amp;gt;&lt;/CODE&gt; search event handler to get the predefined token &lt;CODE&gt;$result.&amp;lt;yourSearchResultFieldName&amp;gt;$&lt;/CODE&gt; to access specific field name. Refer to one of older answer to adopt to your use case: &lt;A href="https://answers.splunk.com/answers/613939/how-to-calculate-percentage-based-on-2-different-s.html"&gt;https://answers.splunk.com/answers/613939/how-to-calculate-percentage-based-on-2-different-s.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 17:50:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416299#M168549</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-07-02T17:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between 2 reports</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416300#M168550</link>
      <description>&lt;P&gt;How many rows does your report generates? (or in other words, how many hosts would be there in a report). What columns should your final (expected) query should show?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 17:51:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416300#M168550</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-02T17:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between 2 reports</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416301#M168551</link>
      <description>&lt;P&gt;hello niletnilnay&lt;/P&gt;

&lt;P&gt;It will be almost perfect but there is a misunderstoog&lt;BR /&gt;
the percentage has to be calculated not between mfetp and mcshield but between mfetp and meftp or between mcshield and mcshield&lt;BR /&gt;
i m explaining : i want to compare between 2 machines (host) the percentage of disk and memory used for a specifique service (mfetp or mcshield)&lt;BR /&gt;
do you understand what i mean?&lt;BR /&gt;
is it possible to adapt the code please?&lt;BR /&gt;
i need also something else : if the result of the percentage is negative (value of first mfetp field &amp;gt; value of second mfetp field) i want for example to display +5% and if the result of the percentage is positive (value of first mfetp field &amp;lt; value of second mfetp field) i want to display -5%&lt;BR /&gt;
could you help me please???&lt;BR /&gt;
many thanks&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 18:34:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416301#M168551</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2018-07-02T18:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage between 2 reports</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416302#M168552</link>
      <description>&lt;P&gt;so i have done this:&lt;/P&gt;

&lt;P&gt;index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" &lt;BR /&gt;
| head 10 &lt;BR /&gt;
| stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG, avg(WriteOperationCount) as mfetp_WriteOperation_AVG, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG &lt;BR /&gt;
| appendcols &lt;BR /&gt;
[ search index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" &lt;BR /&gt;
| head 10 &lt;BR /&gt;
| stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG2, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG2, avg(WriteOperationCount) as mfetp_WriteOperation_AVG2, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG2]&lt;BR /&gt;
 | eval percReadOperation_AVG=round((mfetp_ReadOperation_AVG/mfetp_ReadOperation_AVG2)*100,2),&lt;BR /&gt;
   percReadTransfer_AVG=round((mfetp_ReadTransfer_AVG/mfetp_ReadTransfer_AVG2)*100,2),&lt;BR /&gt;
    percWriteOperation_AVG=round((mfetp_WriteOperation_AVG/mfetp_WriteOperation_AVG2)*100,2),&lt;BR /&gt;
    percWriteTransfer_AVG=round((mfetp_WriteTransfer_AVG/mfetp_WriteTransfer_AVG2)*100,2)&lt;/P&gt;

&lt;P&gt;but there is an issue somewhere because the result is a big number even if i do the test in my local pc&lt;BR /&gt;
so it means for example that i divise 50/50 so the increase is 0%..... What can i do please??&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-percentage-between-2-reports/m-p/416302#M168552</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-29T20:18:50Z</dc:date>
    </item>
  </channel>
</rss>

