<?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: using 2 stats queries in one result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247744#M73905</link>
    <description>&lt;P&gt;sorry, I was wrong| use appendpipe!&lt;BR /&gt;
otherwise there is also join but I usually am trying to avoid this command.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2017 10:50:34 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-01-20T10:50:34Z</dc:date>
    <item>
      <title>using 2 stats queries in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247741#M73902</link>
      <description>&lt;P&gt;I have tried multiple ways to do this including join, append but in each case all I get is one column result being displayed. I asked a similar but more difficult question related to dupes but the counts are still off so I went with the simpler query option.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/logs.stats/tcp/1000" message_type="Log" | bucket _time span=day | stats count(log_id) as totalCount by _time | stats dc(log_id) as nonduplicates by _time | eval dupCount = totalCount - nonduplicates | table nonduplicates uniqueCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please assist with this as I did not realize how difficult some of these panel creations and queries can be.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 10:17:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247741#M73902</guid>
      <dc:creator>jdepp</dc:creator>
      <dc:date>2017-01-20T10:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: using 2 stats queries in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247742#M73903</link>
      <description>&lt;P&gt;Hi jdepp,&lt;BR /&gt;
you should try the appendcols command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/logs.stats/tcp/1000" message_type="Log" 
| bucket _time span=day 
| stats count(log_id) as totalCount by _time 
| appendcols [ search 
   source="/logs.stats/tcp/1000" message_type="Log" 
   | bucket _time span=day 
   | stats dc(log_id) as nonduplicates by _time
   ]
| eval dupCount = totalCount - nonduplicates 
| table nonduplicates uniqueCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in addition I'd use timechart instead stats command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/logs.stats/tcp/1000" message_type="Log" 
| bucket _time span=day 
| timechart count(log_id) as totalCount
| appendcols [ search 
   source="/logs.stats/tcp/1000" message_type="Log" 
   | bucket _time span=day 
   | timechart dc(log_id) as nonduplicates
   ]
| eval dupCount = totalCount - nonduplicates 
| table nonduplicates uniqueCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 10:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247742#M73903</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-01-20T10:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: using 2 stats queries in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247743#M73904</link>
      <description>&lt;P&gt;thanks appreciate the response. Tried the first one and still getting only one column value&lt;/P&gt;

&lt;P&gt;nonduplicates   uniqueCount&lt;BR /&gt;
37694    &lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 10:37:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247743#M73904</guid>
      <dc:creator>jdepp</dc:creator>
      <dc:date>2017-01-20T10:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: using 2 stats queries in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247744#M73905</link>
      <description>&lt;P&gt;sorry, I was wrong| use appendpipe!&lt;BR /&gt;
otherwise there is also join but I usually am trying to avoid this command.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 10:50:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247744#M73905</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-01-20T10:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: using 2 stats queries in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247745#M73906</link>
      <description>&lt;P&gt;Try like this. Since the base search and by clause in stats is same for both your aggregation, you just keep them in one search like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source="/logs.stats/tcp/1000" message_type="Log" | bucket _time span=day | stats count(log_id) as totalCount dc(log_id) as nonduplicates by _time | eval dupCount = totalCount - nonduplicates | table nonduplicates uniqueCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Jan 2017 21:31:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247745#M73906</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-21T21:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: using 2 stats queries in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247746#M73907</link>
      <description>&lt;P&gt;Thanks somesoni2!&lt;BR /&gt;
It worked!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 16:04:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/247746#M73907</guid>
      <dc:creator>opaaa</dc:creator>
      <dc:date>2019-10-14T16:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: using 2 stats queries in one result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/578803#M201715</link>
      <description>&lt;P&gt;This helped me too! Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 20:46:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-2-stats-queries-in-one-result/m-p/578803#M201715</guid>
      <dc:creator>interloper</dc:creator>
      <dc:date>2021-12-17T20:46:40Z</dc:date>
    </item>
  </channel>
</rss>

