<?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: Joining two queries and getting a percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107592#M27964</link>
    <description>&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="norlogs" sourcetype="devicelog" category="NSException" OR category="FinishLaunching" | eval A=if(category=="NSException", 1, 0) | eval B=if(category=="FinishLaunching", 1, 0) | stats sum(A) as TotalA sum(B) as TotalB | eval pct=TotalB/TotalA
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 Apr 2013 18:49:03 GMT</pubDate>
    <dc:creator>emiller42</dc:creator>
    <dc:date>2013-04-26T18:49:03Z</dc:date>
    <item>
      <title>Joining two queries and getting a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107591#M27963</link>
      <description>&lt;P&gt;I have two queries that I am running and I want to take the results / Count of these queries and divide them. I have seen several variances but I am still having issues trying to get my search correct.&lt;/P&gt;

&lt;P&gt;Here is an example of my queries:&lt;/P&gt;

&lt;P&gt;index=norlogs sourcetype="devicelog" category="NSException, on wi-fi:"&lt;/P&gt;

&lt;P&gt;index=norlogs sourcetype="devicelog" category="FinishLaunching"&lt;/P&gt;

&lt;P&gt;I would like to divide the first query by the last query and display a percentage. What would be the best way to accomplish this.&lt;/P&gt;

&lt;P&gt;This is working but I am not getting percentages&lt;/P&gt;

&lt;P&gt;index=norlogs sourcetype="devicelog" category="NSException"| stats count as TotalA | appendcols [search index=norlogs sourcetype="devicelog" category="FinishLaunching" | stats count as TotalB] | eval Total=TotalB/TotalA&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2013 18:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107591#M27963</guid>
      <dc:creator>paul_1994</dc:creator>
      <dc:date>2013-04-26T18:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two queries and getting a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107592#M27964</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="norlogs" sourcetype="devicelog" category="NSException" OR category="FinishLaunching" | eval A=if(category=="NSException", 1, 0) | eval B=if(category=="FinishLaunching", 1, 0) | stats sum(A) as TotalA sum(B) as TotalB | eval pct=TotalB/TotalA
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2013 18:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107592#M27964</guid>
      <dc:creator>emiller42</dc:creator>
      <dc:date>2013-04-26T18:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two queries and getting a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107593#M27965</link>
      <description>&lt;P&gt;Another working solution --&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=norlogs sourcetype=devicelog category="NSException" OR category="FinishLaunching" 
| stats count by sourcetype,category
| xyseries sourcetype, category, count
| eval pct=NSException / FinishLaunching
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2013 18:57:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107593#M27965</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2013-04-26T18:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two queries and getting a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107594#M27966</link>
      <description>&lt;P&gt;(yay IRC!)&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2013 18:57:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107594#M27966</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2013-04-26T18:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two queries and getting a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107595#M27967</link>
      <description>&lt;P&gt;For some reason I could not get this working for me..&lt;/P&gt;

&lt;P&gt;Are these the categories? eval pct=NSException / FinishLaunching&lt;/P&gt;

&lt;P&gt;Also if my categories are more like this " NSexception 222: helpme" will the above still work?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2013 20:07:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107595#M27967</guid>
      <dc:creator>paul_1994</dc:creator>
      <dc:date>2013-04-26T20:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two queries and getting a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107596#M27968</link>
      <description>&lt;P&gt;Yay.. thanks I was able to use this solution.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2013 20:08:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-queries-and-getting-a-percentage/m-p/107596#M27968</guid>
      <dc:creator>paul_1994</dc:creator>
      <dc:date>2013-04-26T20:08:09Z</dc:date>
    </item>
  </channel>
</rss>

