<?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 Timechart with multiple fields and calculating percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-multiple-fields-and-calculating-percentage/m-p/40922#M9477</link>
    <description>&lt;P&gt;My query is something like&lt;/P&gt;

&lt;P&gt;.. | eval color_and_shape = color + "/" + shape&lt;BR /&gt;
| timechart count as total, count(eval(heavy="true")) as heavy by color_and_shape&lt;/P&gt;

&lt;P&gt;which returns a table similar to&lt;/P&gt;

&lt;P&gt;_time       heavy:green/triangle   heavy:green/circle  total:green/triangle total:green/circle&lt;/P&gt;

&lt;P&gt;11/20/12      1                                         2                        5                            6&lt;/P&gt;

&lt;P&gt;How would I go about calculating the percentage of shapes that a heavy by color_and_shape?&lt;/P&gt;

&lt;P&gt;I tried doing ...| eval pct=sc/total &lt;BR /&gt;
but this does not work.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 12:50:32 GMT</pubDate>
    <dc:creator>benobviate</dc:creator>
    <dc:date>2020-09-28T12:50:32Z</dc:date>
    <item>
      <title>Timechart with multiple fields and calculating percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-multiple-fields-and-calculating-percentage/m-p/40922#M9477</link>
      <description>&lt;P&gt;My query is something like&lt;/P&gt;

&lt;P&gt;.. | eval color_and_shape = color + "/" + shape&lt;BR /&gt;
| timechart count as total, count(eval(heavy="true")) as heavy by color_and_shape&lt;/P&gt;

&lt;P&gt;which returns a table similar to&lt;/P&gt;

&lt;P&gt;_time       heavy:green/triangle   heavy:green/circle  total:green/triangle total:green/circle&lt;/P&gt;

&lt;P&gt;11/20/12      1                                         2                        5                            6&lt;/P&gt;

&lt;P&gt;How would I go about calculating the percentage of shapes that a heavy by color_and_shape?&lt;/P&gt;

&lt;P&gt;I tried doing ...| eval pct=sc/total &lt;BR /&gt;
but this does not work.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-multiple-fields-and-calculating-percentage/m-p/40922#M9477</guid>
      <dc:creator>benobviate</dc:creator>
      <dc:date>2020-09-28T12:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart with multiple fields and calculating percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-with-multiple-fields-and-calculating-percentage/m-p/40923#M9478</link>
      <description>&lt;P&gt;The problem is that after you've run the results through timechart, you no longer know all the combinations of column headers you'll need to calculate the percentage.&lt;/P&gt;

&lt;P&gt;A better way of approaching this would be to work out the percentages before running timechart like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval color_and_shape = color + "/" + shape
    | bin _time span=1d 
    | stats count as total, count(eval(heavy="true")) as heavy by color_and_shape _time 
    | eval perc_heavy=100*heavy/total 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can do the timechart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart span=1d first(total) as total first(heavy) as heavy first(perc_heavy) as perc_heavy by color_and_shape
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2012 00:26:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-with-multiple-fields-and-calculating-percentage/m-p/40923#M9478</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-11-21T00:26:45Z</dc:date>
    </item>
  </channel>
</rss>

