<?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 How to use the stored results in variables after stats command using by clause in calculation ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/470579#M132380</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm using the below query in order retrieve average and standard deviation for the respective days (mon,tue,wed, etc. ) for each warehouse for the last 90 days and i want to use the output values in other calculation in order to retrieve the limits. &lt;/P&gt;

&lt;P&gt;Could you please help how i can achieve this ? How are the values retrieved from stats command by clause are stored internally and how i can assign them to new variable matrix etc ? &lt;/P&gt;

&lt;P&gt;Search Query:&lt;BR /&gt;
index="orderstowh" &lt;BR /&gt;
| where in (WH,1,2,3,4,5,6,7,8,9) &lt;BR /&gt;
| timechart span=1d count as "Total" by WH&lt;BR /&gt;
| untable _time  WH Total&lt;BR /&gt;
| eval dayofweek=strftime(_time,"%w") &lt;BR /&gt;
| where dayofweek in (1,2,3,4,5)&lt;BR /&gt;
| stats avg(Total) as avg stdev(Total) as stdev by WH,dayofweek&lt;BR /&gt;
...........................&lt;BR /&gt;
| eval lowerBound[WH,dayofweek]=(avg[WH,dayofweek]-(stdev[WH,dayofweek]) )&lt;BR /&gt;
| eval upperBound[WH,dayofweek]=(avg[WH,dayofweek]+(stdev[WH,dayofweek]) )&lt;/P&gt;

&lt;P&gt;Thanks in advance!!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:02:39 GMT</pubDate>
    <dc:creator>vinaybandaru</dc:creator>
    <dc:date>2020-09-30T02:02:39Z</dc:date>
    <item>
      <title>How to use the stored results in variables after stats command using by clause in calculation ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/470579#M132380</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm using the below query in order retrieve average and standard deviation for the respective days (mon,tue,wed, etc. ) for each warehouse for the last 90 days and i want to use the output values in other calculation in order to retrieve the limits. &lt;/P&gt;

&lt;P&gt;Could you please help how i can achieve this ? How are the values retrieved from stats command by clause are stored internally and how i can assign them to new variable matrix etc ? &lt;/P&gt;

&lt;P&gt;Search Query:&lt;BR /&gt;
index="orderstowh" &lt;BR /&gt;
| where in (WH,1,2,3,4,5,6,7,8,9) &lt;BR /&gt;
| timechart span=1d count as "Total" by WH&lt;BR /&gt;
| untable _time  WH Total&lt;BR /&gt;
| eval dayofweek=strftime(_time,"%w") &lt;BR /&gt;
| where dayofweek in (1,2,3,4,5)&lt;BR /&gt;
| stats avg(Total) as avg stdev(Total) as stdev by WH,dayofweek&lt;BR /&gt;
...........................&lt;BR /&gt;
| eval lowerBound[WH,dayofweek]=(avg[WH,dayofweek]-(stdev[WH,dayofweek]) )&lt;BR /&gt;
| eval upperBound[WH,dayofweek]=(avg[WH,dayofweek]+(stdev[WH,dayofweek]) )&lt;/P&gt;

&lt;P&gt;Thanks in advance!!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:02:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/470579#M132380</guid>
      <dc:creator>vinaybandaru</dc:creator>
      <dc:date>2020-09-30T02:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the stored results in variables after stats command using by clause in calculation ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/470580#M132381</link>
      <description>&lt;P&gt;The results of the &lt;CODE&gt;stats&lt;/CODE&gt; command are stored in fields named using the words that follow &lt;CODE&gt;as&lt;/CODE&gt; and &lt;CODE&gt;by&lt;/CODE&gt;.  In your example, the results are in 'avg', 'stdev', 'WH', and 'dayofweek'.  Each field is separate - there are no tuples in Splunk.  Display the output from &lt;CODE&gt;stats&lt;/CODE&gt; and you'll see there's a different row for each combination of 'WH' and 'dayofweek' so any &lt;CODE&gt;evals&lt;/CODE&gt; will be calculated using those separate results.  Therefore, you can use &lt;CODE&gt;| eval lowerBound=avg-stdev, upperBound=avg+stdev&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 13:03:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/470580#M132381</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-09-03T13:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the stored results in variables after stats command using by clause in calculation ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/470581#M132382</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thank you it works !! &lt;/P&gt;

&lt;P&gt;index="orderstowh" &lt;BR /&gt;
| where in (WH,1,2,3,4,5,6,7,8,9) &lt;BR /&gt;
| timechart span=1d count as "Total" by WH&lt;BR /&gt;
| untable _time WH Total&lt;BR /&gt;
| eval dayofweek=strftime(_time,"%w") &lt;BR /&gt;
| where dayofweek in (1,2,3,4,5)&lt;BR /&gt;
| stats avg(Total) as avg stdev(Total) as stdev by WH,dayofweek&lt;BR /&gt;
| eval lowerBound=(avg-(stdev) )&lt;BR /&gt;
| eval upperBound=(avg+(stdev) )&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/470581#M132382</guid>
      <dc:creator>vinaybandaru</dc:creator>
      <dc:date>2020-09-30T02:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the stored results in variables after stats command using by clause in calculation ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/505027#M141055</link>
      <description>&lt;P&gt;I'm not sure that works. In my case it doesn't show anything and I'm using the same as you.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=blueprism sourcetype=BP_Parkour_Status source=TABLA::RPA_BLUEPRISM 
| bin span=1d _time 
| stats count as total by _time
| where tipoexcep="Business Exception" 
| stats count as totalDetalle by detalexcep _time
| eval porc=totalDetalle/total*100
| table totalDetalle total porc&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 16:10:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-stored-results-in-variables-after-stats-command/m-p/505027#M141055</guid>
      <dc:creator>rmanrique</dc:creator>
      <dc:date>2020-06-18T16:10:01Z</dc:date>
    </item>
  </channel>
</rss>

