<?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 create two searches combined into one chart, or timechart with calculated percent of total (rate) by fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-two-searches-combined-into-one-chart-or-timechart/m-p/346339#M102589</link>
    <description>&lt;P&gt;Try this; it may not be the most efficient search, but it should work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=server* "Catering" txnType=order | timechart span=1d dc(txnId) as "totalTxns"
| append [ search host=server* "Catering" txnType=order issuerResponse="authorized" 
           NOT ("avsMismatch" OR "cvvMismatch") 
     | timechart span=1d dc(txnId) by Decision 
     | rename APPROVE as "Accept", REJECT as "Decline", ERROR as "Error" ]
| stats first(*) as * by _time
| foreach Accept Decline Error [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_percentOfTotal=(round((&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;/totalTxns)*100)."%") ]
| rename _time as Date, Accept_percentOfTotal as "Accept %", Decline_percentOfTotal as "Decline %",
      Error_percentOfTotal as "Error %", totalTxns as "Total Txn"
| table Date "Total Txn" Accept "Accept %"  Decline "Decline %" Error  "Error %"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 05 Feb 2018 20:33:04 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2018-02-05T20:33:04Z</dc:date>
    <item>
      <title>How to create two searches combined into one chart, or timechart with calculated percent of total (rate) by fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-two-searches-combined-into-one-chart-or-timechart/m-p/346338#M102588</link>
      <description>&lt;P&gt;I have transactions logged across different sales "channels" (catering, mobileApp, faceToFace, etc.). I am trying to display the transaction &lt;CODE&gt;Decision&lt;/CODE&gt; counts along with the &lt;CODE&gt;percentOfTotal&lt;/CODE&gt; (Rate) of each &lt;CODE&gt;Decision&lt;/CODE&gt; type.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;first search:&lt;/STRONG&gt;&lt;BR /&gt;
&lt;CODE&gt;host=server* "Catering" txnType=order | timechart span=1d dc(txnId) as "totalTxns"&lt;/CODE&gt; &amp;lt;&amp;lt; this base search is a discrete total of all transactions in all use cases in the catering channel.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;second search:&lt;/STRONG&gt;&lt;BR /&gt;
&lt;CODE&gt;host=server* "Catering" txnType=order issuerResponse="authorized" NOT ("avsMismatch" OR "cvvMismatch") | timechart span=1d dc(txnId) by Decision | rename APPROVE as "Accept", REJECT as "Decline", ERROR as "Error"&lt;/CODE&gt; &amp;lt;&amp;lt; this base search is one use case in the catering channel that is a subset of the first search. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;calculation:&lt;/STRONG&gt;&lt;BR /&gt;
&lt;CODE&gt;| eval percentOfTotal=(round((Decision/totalTxns)*100)."%")&lt;/CODE&gt; &amp;lt;&amp;lt; I'm intending for this to be &lt;CODE&gt;percentOfTotal&lt;/CODE&gt; displayed in a chart for each of the three &lt;CODE&gt;Decision&lt;/CODE&gt; types (Accept, Decline, Error) found in the second search over a span=1d. However, in attempting to chart this doesn't seem like a way to accomplish what I am trying to do. &lt;/P&gt;

&lt;P&gt;Ideally the data could be presented similar to the following:&lt;/P&gt;

&lt;P&gt;-&lt;CODE&gt;totalTxns&lt;/CODE&gt; being greater than the sum of all &lt;CODE&gt;Decisions&lt;/CODE&gt; is expected as this is only one specific use case within this channel.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4271i065E3946AC7D6710/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 18:37:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-two-searches-combined-into-one-chart-or-timechart/m-p/346338#M102588</guid>
      <dc:creator>rvazquez8113</dc:creator>
      <dc:date>2018-02-05T18:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create two searches combined into one chart, or timechart with calculated percent of total (rate) by fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-two-searches-combined-into-one-chart-or-timechart/m-p/346339#M102589</link>
      <description>&lt;P&gt;Try this; it may not be the most efficient search, but it should work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=server* "Catering" txnType=order | timechart span=1d dc(txnId) as "totalTxns"
| append [ search host=server* "Catering" txnType=order issuerResponse="authorized" 
           NOT ("avsMismatch" OR "cvvMismatch") 
     | timechart span=1d dc(txnId) by Decision 
     | rename APPROVE as "Accept", REJECT as "Decline", ERROR as "Error" ]
| stats first(*) as * by _time
| foreach Accept Decline Error [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_percentOfTotal=(round((&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;/totalTxns)*100)."%") ]
| rename _time as Date, Accept_percentOfTotal as "Accept %", Decline_percentOfTotal as "Decline %",
      Error_percentOfTotal as "Error %", totalTxns as "Total Txn"
| table Date "Total Txn" Accept "Accept %"  Decline "Decline %" Error  "Error %"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Feb 2018 20:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-two-searches-combined-into-one-chart-or-timechart/m-p/346339#M102589</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2018-02-05T20:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create two searches combined into one chart, or timechart with calculated percent of total (rate) by fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-two-searches-combined-into-one-chart-or-timechart/m-p/346340#M102590</link>
      <description>&lt;P&gt;Thank you Iguinn! absolutely brilliant! &lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 23:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-two-searches-combined-into-one-chart-or-timechart/m-p/346340#M102590</guid>
      <dc:creator>rvazquez8113</dc:creator>
      <dc:date>2018-02-06T23:49:46Z</dc:date>
    </item>
  </channel>
</rss>

