<?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 % of each field as ratio? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-of-each-field-as-ratio/m-p/450316#M191235</link>
    <description>&lt;P&gt;I never use Foreach before. thank you for giving this query. It works&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2019 15:19:49 GMT</pubDate>
    <dc:creator>Joycetran</dc:creator>
    <dc:date>2019-08-15T15:19:49Z</dc:date>
    <item>
      <title>Calculate % of each field as ratio?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-of-each-field-as-ratio/m-p/450314#M191233</link>
      <description>&lt;P&gt;I have the table: &lt;BR /&gt;
_time           Ip_1                  Ip_2              Ip_3&lt;BR /&gt;
a                   36                      40                  31&lt;BR /&gt;
b                   37                      39                  21&lt;/P&gt;

&lt;P&gt;I want to take the percentage of each IP instead count,  like:&lt;BR /&gt;
&lt;STRONG&gt;a                  0.33                     0.37              0.28&lt;/STRONG&gt;&lt;BR /&gt;
The table above From the query:&lt;BR /&gt;
base search |  | stats dc(sid) AS distinct_search_count by provenance, mode, app, type, user, host, _time&lt;BR /&gt;&lt;BR /&gt;
| stats sum(distinct_search_count) as total_distinct_search_count by provenance, mode, app, type, user, host, _time&lt;/P&gt;

&lt;P&gt;How can I add the percentage in the query?&lt;BR /&gt;
          | timechart minspan=10s partial=false Max(total_distinct_search_count) as search_count by host&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:46:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-of-each-field-as-ratio/m-p/450314#M191233</guid>
      <dc:creator>Joycetran</dc:creator>
      <dc:date>2020-09-30T01:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate % of each field as ratio?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-of-each-field-as-ratio/m-p/450315#M191234</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | | stats dc(sid) AS distinct_search_count by provenance, mode, app, type, user, host, _time 
| stats sum(distinct_search_count) as total_distinct_search_count by provenance, mode, app, type, user, host, _time
| timechart minspan=10s partial=false Max(total_distinct_search_count) as search_count by host
| addtotals 
| foreach * [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"!="Total", round('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/Total,2), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;') ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Aug 2019 14:47:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-of-each-field-as-ratio/m-p/450315#M191234</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-08-14T14:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate % of each field as ratio?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-of-each-field-as-ratio/m-p/450316#M191235</link>
      <description>&lt;P&gt;I never use Foreach before. thank you for giving this query. It works&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 15:19:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-of-each-field-as-ratio/m-p/450316#M191235</guid>
      <dc:creator>Joycetran</dc:creator>
      <dc:date>2019-08-15T15:19:49Z</dc:date>
    </item>
  </channel>
</rss>

