<?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 calculate percentage based on 2 different searches? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/336000#M99776</link>
    <description>&lt;P&gt;@albinortiz, good to know.. glad you found it working!!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2018 14:41:29 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-01-29T14:41:29Z</dc:date>
    <item>
      <title>How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335991#M99767</link>
      <description>&lt;P&gt;Greetings to the pro's,&lt;/P&gt;

&lt;P&gt;I have 2 panels, one brings me the Total Active Hosts and the other brings me the Total Hosts. By Total Active Hosts I mean that they are currently ONLINE and by Total Hosts I mean the total count in Active Directory. What I am trying to do is to have the percentage display in a panel &lt;CODE&gt;Total_Active_Hosts/Total_Hosts)*100 = %&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;For the Active Host panel I use this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=winevents | dedup host | stats count(host)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For the total host panel I use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ldapsearch search="(objectClass=computer") attrs="cn, operatingSystem, operatingSystemVersion" 
|  lookup dnslookup clienthost AS cn | search (opeartingSystem="Win*") | stats count(cn)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is what I have so far of the Percentage panel:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=winevents | dedup host
| append [ | ldapsearch search="(objectClass=computer") attrs="cn, operatingSystem, operatingSystemVersion" 
| lookup dnslookup clienthost AS cn | search (opeartingSystem="Win*")] 
| stats count(eval(Total_Hosts)) AS cn, count(eval(Total_Active_Hosts)) AS host
| eval Percentage = (Total_Active_Hosts / Total_Hosts) *100 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If there is any better way to do this, please let me know.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:13:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335991#M99767</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-01-26T17:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335992#M99768</link>
      <description>&lt;P&gt;@albinortiz, you have two ways to do it (Option 2 does not use append so it should perform better):&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 1: Use combined search to calculate percent and display results using tokens in two different panels&lt;/STRONG&gt;&lt;BR /&gt;
In your case you will just have the third search with two searches appended together to set the tokens. Following is a run anywhere example using Splunk's _internal index:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Percent from two panels - Option 1&amp;lt;/label&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level=* earliest=-24h@h latest=now
| stats count as Total
| appendcols [search index=_internal sourcetype=splunkd log_level!="INFO" earliest=-24h@h latest=now
| stats count as Error]
| eval Percent=round((Error/Total)*100,1)
    &amp;lt;/query&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;set token="tokTotal"&amp;gt;$result.Total$&amp;lt;/set&amp;gt;
      &amp;lt;set token="tokError"&amp;gt;$result.Error$&amp;lt;/set&amp;gt;
      &amp;lt;set token="tokPercent"&amp;gt;$result.Percent$&amp;lt;/set&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Total&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults | eval Total=$tokTotal$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Errors&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults | eval Error=$tokError$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Percent&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults | eval Percent=$tokPercent$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="unit"&amp;gt;%&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2: Use separate searches for Total and Active hosts and set tokens from both to be used in third panel for percent&lt;/STRONG&gt;&lt;BR /&gt;
In your case this will have first and second search but not the third combined search for percent as tokens from first two searches will be used in the third one&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Percent from two panels - Option 2&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Total&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level=* earliest=-24h@h latest=now
| stats count as Total&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="tokTotalCount"&amp;gt;$result.Total$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Errors&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd log_level!="INFO" earliest=-24h@h latest=now
| stats count as Error
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="tokErrorCount"&amp;gt;$result.Error$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Percent&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults | eval Total=$tokTotalCount$, Error=$tokErrorCount$ | eval percent= round((Error/Total)*100,1) | table percent&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="unit"&amp;gt;%&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: I have used &lt;CODE&gt;&amp;lt;done&amp;gt;&lt;/CODE&gt; search event handler to access the search result to be assigned as token (you can also use &lt;CODE&gt;&amp;lt;progress&amp;gt;&lt;/CODE&gt;).&lt;BR /&gt;
For example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;       &amp;lt;done&amp;gt;
         &amp;lt;set token="tokErrorCount"&amp;gt;$result.Error$&amp;lt;/set&amp;gt;
       &amp;lt;/done&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer to Splunk Documentation: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/EventHandlerReference#done"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/EventHandlerReference#done&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 17:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335992#M99768</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-01-26T17:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335993#M99769</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;&lt;/P&gt;

&lt;P&gt;I was looking at both proposed solutions and tried using the second one. Should I replace the queries with my own?&lt;/P&gt;

&lt;P&gt;i.e. replace this:&lt;/P&gt;

&lt;P&gt;index=_internal sourcetype=splunkd log_level=* earliest=-24h@h latest=now&lt;BR /&gt;
| stats count as Total&lt;/P&gt;

&lt;P&gt;with this?:&lt;/P&gt;

&lt;P&gt;index=winevents | dedup host earliest=-24h@h latest=now&lt;BR /&gt;
| stats count as Total&lt;/P&gt;

&lt;P&gt;I'm no expert at any of this but I'm sure trying my best.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:51:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335993#M99769</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2020-09-29T17:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335994#M99770</link>
      <description>&lt;P&gt;NVM. I replaced them with my strings and they project the right data now. The only issue is that the token is not passing anything (no calculation is being done).&lt;/P&gt;

&lt;P&gt;I probably forgot to mention that I am not using a table. I think this part is what is not working:&lt;/P&gt;

&lt;P&gt;... | table percent&lt;/P&gt;

&lt;P&gt;I am using a dashboard panel not a table. &lt;/P&gt;

&lt;P&gt;Any other ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 20:41:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335994#M99770</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-01-26T20:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335995#M99771</link>
      <description>&lt;P&gt;Try something like this(check the time-ragne on the baseSearch. If you're using a timerange picker, you need to specify corresponding token in earliest/latest tags). Basically both searches are combined and populating 3 panels.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;Dashboard with post-process search&amp;lt;/label&amp;gt;
  &amp;lt;!-- This limits events passed to post-process search --&amp;gt;
  &amp;lt;search id="baseSearch"&amp;gt;
    &amp;lt;query&amp;gt;
     | ldapsearch search="(objectClass=computer") attrs="cn, operatingSystem, operatingSystemVersion" 
     |  lookup dnslookup clienthost AS cn | search (opeartingSystem="Win*") | stats count(cn) as Total_Active_Hosts
     | appendcols [| tstats count WHERE index=winevents by host | stats count as Total_Hosts]      
    &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-1d@d&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/search&amp;gt;    
 &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Total Host Count&amp;lt;/title&amp;gt;

        &amp;lt;!-- post-process search --&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt;
            table Total_Hosts
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Total Active Host Count&amp;lt;/title&amp;gt;

        &amp;lt;!-- post-process search --&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt;
            table Total_Active_Hosts
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Active Host Percentage&amp;lt;/title&amp;gt;
        &amp;lt;!-- post-process search --&amp;gt;
        &amp;lt;search base="baseSearch"&amp;gt;
          &amp;lt;query&amp;gt;
            eval Percentage = (Total_Active_Hosts / Total_Hosts) *100  | table Percentage
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jan 2018 22:03:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335995#M99771</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-26T22:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335996#M99772</link>
      <description>&lt;P&gt;@somesoni2&lt;/P&gt;

&lt;P&gt;I have something so far but I am not using a table rather, I am trying to display the result in a panel in my dashboard. The intent is to show one panel with the total hosts in AD, one panel with the hosts that are active, and what percent of the total hosts are active.&lt;/P&gt;

&lt;P&gt;How would I present that Percentage?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2018 00:22:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335996#M99772</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-01-27T00:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335997#M99773</link>
      <description>&lt;P&gt;@albinortiz, you would also need to change the tokens being set in done search event handler as per your search. While setting the token in &lt;CODE&gt;&amp;lt;done&amp;gt;&lt;/CODE&gt; search event handler, the name of field in default token &lt;CODE&gt;$result.&amp;lt;fieldname&amp;gt;$&lt;/CODE&gt; should match exactly with the field name in the query.&lt;/P&gt;

&lt;P&gt;For example search with field &lt;CODE&gt;Total_Hosts&lt;/CODE&gt; i.e. &lt;CODE&gt;... | table Total_Hosts&lt;/CODE&gt; is &lt;CODE&gt;$result.Total_Hosts$&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;set token="tokTotalHostCount"&amp;gt;$result.Total_Hosts$&amp;lt;/set&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And for search with field &lt;CODE&gt;Total_Active_Hosts&lt;/CODE&gt; i.e. &lt;CODE&gt;... | table Total_Active_Hosts&lt;/CODE&gt; is &lt;CODE&gt;$result.Total_Active_Hosts$&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;set token="tokActiveHostCount"&amp;gt;$result.Total_Active_Hosts$&amp;lt;/set&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally, you can also display the tokens &lt;CODE&gt;$tokTotalHostCount$&lt;/CODE&gt; and &lt;CODE&gt;$tokActiveHostCount$&lt;/CODE&gt; in the Single Value Panel &lt;CODE&gt;&amp;lt;title&amp;gt;&lt;/CODE&gt; to check whether they are being set or not&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;single&amp;gt;
     &amp;lt;title&amp;gt;Percent - $tokTotalHostCount$ $tokActiveHostCount$&amp;lt;/title&amp;gt;
     &amp;lt;search&amp;gt;
       &amp;lt;query&amp;gt;| makeresults | eval Total=$tokTotalHostCount$, Active=$tokActiveHostCount$ | eval percent= round((Active/Total)*100,1) | table percent&amp;lt;/query&amp;gt;
       &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
       &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
       &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
     &amp;lt;/search&amp;gt;
     &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
     &amp;lt;option name="unit"&amp;gt;%&amp;lt;/option&amp;gt;
     &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
   &amp;lt;/single&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please ensure that above changes are in place and confirm. If you see any text values like &lt;CODE&gt;$tokTotalHostCount$&lt;/CODE&gt; and &lt;CODE&gt;$tokActiveHostCount$&lt;/CODE&gt; instead of numeric value in the third panel title, then it confirms that tokens are not being set properly and you would need to check and ensure that the field names in first two searches match with their respective field names in &lt;CODE&gt;$result.&amp;lt;fieldName&amp;gt;$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2018 03:56:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335997#M99773</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-01-27T03:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335998#M99774</link>
      <description>&lt;P&gt;I will try this tomorrow. Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 17:27:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335998#M99774</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-01-28T17:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335999#M99775</link>
      <description>&lt;P&gt;You are amazing! After I rechecked it today. I found the issue. The problem was that I was not displaying the result value. I had a typo on one of the token variables.&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 13:46:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/335999#M99775</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-01-29T13:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/336000#M99776</link>
      <description>&lt;P&gt;@albinortiz, good to know.. glad you found it working!!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 14:41:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/336000#M99776</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-01-29T14:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/336001#M99777</link>
      <description>&lt;P&gt;Is there a way I can have this on one single panel?&lt;/P&gt;

&lt;P&gt;What I am trying to do is to calculate the percentage difference, then have the Total Active Hosts display color change according to the percentage.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 18:20:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/336001#M99777</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-02-05T18:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate percentage based on 2 different searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/336002#M99778</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;i am attempting the second alternative. For some reason, the code modifies the sequence of the code. I place [...] after the 1. When I close and return into the code it puts it before the &lt;/P&gt;

&lt;P&gt;So below is my code. I am getting the Total average time in the first panel. The second panel segments the average by either virtual machine or physical desktop. &lt;/P&gt;

&lt;P&gt;I am trying to get the % delta between the time with a virtual machine compared to a physical desktop. &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Smallworld - Performance globale&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="true" autoRun="true"&amp;gt;
    &amp;lt;input type="time" token="field1"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Smallworld - Temps de charge de l'application (V1)&amp;lt;/title&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Temps moyen de charge - total&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="tokTotalCount"&amp;gt;$result.avg_duration_total$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
          &amp;lt;query&amp;gt;index=diag_sw_prod sourcetype="rwa_code_load" load_type="load_module"  NOT user_name=swadmin|eval location = coalesce(location,"VM") |search (location="*") (user_name=*)  | stats earliest(_time) as start_load_module by user_name session_id | join type=left session_id [|search index=diag_sw_prod sourcetype=rwr_jvm_statistics | stats latest(vm_uptime) as uptime latest(_time) as time by session_id | eval startup_time=time-uptime| fields startup_time session_id] | join type=left session_id  [search index=diag_sw_prod sourcetype=rwa_custom_function user_action=startup_profiling handler_class=smallworld_product message="open_database()" message_args=*\\* | stats earliest(_time) as start_open_db by session_id] | join type=left session_id  [search index=diag_sw_prod sourcetype=rwa_custom_function user_action=startup_profiling handler_class=smallworld_product message="login()" | stats earliest(_time) as login by session_id]| eval bootstrapping=start_load_module-startup_time , loading_module_time=start_open_db-start_load_module, open_db_time=login-start_open_db, total_time=bootstrapping+loading_module_time+open_db_time |convert ctime(startup_time) | stats avg(total_time) as avg_duration_total&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$field1.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$field1.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="colorMode"&amp;gt;block&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;all&amp;lt;/option&amp;gt;
        &amp;lt;option name="height"&amp;gt;206&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeColors"&amp;gt;["0x53a051","0xdc4e41"]&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeValues"&amp;gt;[300]&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
        &amp;lt;option name="unit"&amp;gt;sec.&amp;lt;/option&amp;gt;
        &amp;lt;option name="useColors"&amp;gt;1&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Smallworld - Temps de charge de l'application - Machine virtuelle vs poste physique&amp;lt;/title&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Machine virtuelle&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="tokVMCount"&amp;gt;$result.avg_duration_VM$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
          &amp;lt;query&amp;gt;index=diag_sw_prod sourcetype="rwa_code_load" load_type="load_module"  NOT user_name=swadmin|eval location = coalesce(location,"VM") |search (location="VM") (user_name=*)  | stats earliest(_time) as start_load_module by user_name session_id | join type=left session_id [|search index=diag_sw_prod sourcetype=rwr_jvm_statistics | stats latest(vm_uptime) as uptime latest(_time) as time by session_id | eval startup_time=time-uptime| fields startup_time session_id] | join type=left session_id  [search index=diag_sw_prod sourcetype=rwa_custom_function user_action=startup_profiling handler_class=smallworld_product message="open_database()" message_args=*\\* | stats earliest(_time) as start_open_db by session_id] | join type=left session_id  [search index=diag_sw_prod sourcetype=rwa_custom_function user_action=startup_profiling handler_class=smallworld_product message="login()" | stats earliest(_time) as login by session_id]| eval bootstrapping=start_load_module-startup_time , loading_module_time=start_open_db-start_load_module, open_db_time=login-start_open_db, total_time=bootstrapping+loading_module_time+open_db_time |convert ctime(startup_time) | stats avg(total_time) as avg_duration_VM&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$field1.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$field1.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;all&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeColors"&amp;gt;["0x53a051","0xdc4e41"]&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeValues"&amp;gt;[300]&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
        &amp;lt;option name="trellis.enabled"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="trellis.splitBy"&amp;gt;_aggregation&amp;lt;/option&amp;gt;
        &amp;lt;option name="unit"&amp;gt;sec.&amp;lt;/option&amp;gt;
        &amp;lt;option name="useColors"&amp;gt;1&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Poste physique&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;set token="tokPPCount"&amp;gt;$result.avg_duration_PP$&amp;lt;/set&amp;gt;
          &amp;lt;/done&amp;gt;
          &amp;lt;query&amp;gt;index=diag_sw_prod sourcetype="rwa_code_load" load_type="load_module"  NOT user_name=swadmin|eval location = coalesce(location,"VM") |search (location="Site locations") (user_name=*)  | stats earliest(_time) as start_load_module by user_name session_id | join type=left session_id [|search index=diag_sw_prod sourcetype=rwr_jvm_statistics | stats latest(vm_uptime) as uptime latest(_time) as time by session_id | eval startup_time=time-uptime| fields startup_time session_id] | join type=left session_id  [search index=diag_sw_prod sourcetype=rwa_custom_function user_action=startup_profiling handler_class=smallworld_product message="open_database()" message_args=*\\* | stats earliest(_time) as start_open_db by session_id] | join type=left session_id  [search index=diag_sw_prod sourcetype=rwa_custom_function user_action=startup_profiling handler_class=smallworld_product message="login()" | stats earliest(_time) as login by session_id]| eval bootstrapping=start_load_module-startup_time , loading_module_time=start_open_db-start_load_module, open_db_time=login-start_open_db, total_time=bootstrapping+loading_module_time+open_db_time |convert ctime(startup_time) | stats avg(total_time) as avg_duration_PP&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$field1.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$field1.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;all&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeColors"&amp;gt;["0x53a051","0xdc4e41"]&amp;lt;/option&amp;gt;
        &amp;lt;option name="rangeValues"&amp;gt;[300]&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
        &amp;lt;option name="trellis.enabled"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="trellis.size"&amp;gt;large&amp;lt;/option&amp;gt;
        &amp;lt;option name="unit"&amp;gt;sec.&amp;lt;/option&amp;gt;
        &amp;lt;option name="useColors"&amp;gt;1&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;title&amp;gt;Différence de performance&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;makeresults | eval Total=$tokTotalCount$, TotalVM=$tokVMCount$, TotalPP=$tokPPCount$ | eval percent= round((abs(TotalVM-TotalPP)/Total)*100,1) | table percent&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$field1.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$field1.latest$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
        &amp;lt;option name="unit"&amp;gt;%&amp;lt;/option&amp;gt;
        &amp;lt;option name="useThousandSeparators"&amp;gt;0&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Feb 2020 16:59:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-percentage-based-on-2-different-searches/m-p/336002#M99778</guid>
      <dc:creator>leemburg</dc:creator>
      <dc:date>2020-02-25T16:59:51Z</dc:date>
    </item>
  </channel>
</rss>

