<?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 Stats Values and Count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305743#M91801</link>
    <description>&lt;P&gt;Hi, I wonder if someone could help me please.&lt;/P&gt;

&lt;P&gt;I'm trying to 'join' two queries using the 'stats values' for efficiency purposes.&lt;/P&gt;

&lt;P&gt;This is the query I've put together so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch
[ search `it_wmf(OutboundCall)`]
[ search `it_wmf(RequestReceived)` detail.responseMessage!=""]
| spath output=ITREF1 input=detail.responseMessage path=itRef
| spath output=given input=detail.responseMessage path=allGifts.isGivenAway
| rex field=request.detail.path "cases\/(?&amp;lt;ITREF2&amp;gt;[^\W]+)\/"
| search given="true"
| stats count values(auditSource) as auditSource values(given) as given by ITREF1, ITREF2
| where (auditSource="it" AND auditType=OutBoundCall AND auditType=RequestReceived)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm trying to join the queries on the ITREF's but because I've had to give these two different fieldnames i.e ITREF1 and ITREF2 I'm not sure how to join them.&lt;/P&gt;

&lt;P&gt;In addition I'd then like to create a distinct count of the ITREF.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone could look at this please and offer some guidance on how I may achieve this?&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2017 08:15:53 GMT</pubDate>
    <dc:creator>IRHM73</dc:creator>
    <dc:date>2017-07-13T08:15:53Z</dc:date>
    <item>
      <title>Stats Values and Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305743#M91801</link>
      <description>&lt;P&gt;Hi, I wonder if someone could help me please.&lt;/P&gt;

&lt;P&gt;I'm trying to 'join' two queries using the 'stats values' for efficiency purposes.&lt;/P&gt;

&lt;P&gt;This is the query I've put together so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch
[ search `it_wmf(OutboundCall)`]
[ search `it_wmf(RequestReceived)` detail.responseMessage!=""]
| spath output=ITREF1 input=detail.responseMessage path=itRef
| spath output=given input=detail.responseMessage path=allGifts.isGivenAway
| rex field=request.detail.path "cases\/(?&amp;lt;ITREF2&amp;gt;[^\W]+)\/"
| search given="true"
| stats count values(auditSource) as auditSource values(given) as given by ITREF1, ITREF2
| where (auditSource="it" AND auditType=OutBoundCall AND auditType=RequestReceived)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm trying to join the queries on the ITREF's but because I've had to give these two different fieldnames i.e ITREF1 and ITREF2 I'm not sure how to join them.&lt;/P&gt;

&lt;P&gt;In addition I'd then like to create a distinct count of the ITREF.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone could look at this please and offer some guidance on how I may achieve this?&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 08:15:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305743#M91801</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-07-13T08:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Stats Values and Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305744#M91802</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;coalesce&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| search given="true"
| eval ITREF=coalesce(ITREF1,ITREF2)
| stats count values(auditSource) as auditSource values(given) as given by ITREF
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:38:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305744#M91802</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-07-13T11:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Stats Values and Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305745#M91803</link>
      <description>&lt;P&gt;if before your stats command you create a field &lt;CODE&gt;|eval ITREF=coalesce(ITREF1,ITREF2)&lt;/CODE&gt; and use the new ITREF field as the by arguement &lt;CODE&gt;| stats count values(auditSource) as auditSource values(given) as given by ITREF&lt;/CODE&gt;, would that work?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:39:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305745#M91803</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-07-13T11:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Stats Values and Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305746#M91804</link>
      <description>&lt;P&gt;Hi, please see my solution below. I found out that because I was extracting the ITREF field with separate methods I could allocate the same field name to them.&lt;/P&gt;

&lt;P&gt;Many thanks for taking the time to reply.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:15:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305746#M91804</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-07-13T12:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Stats Values and Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305747#M91805</link>
      <description>&lt;P&gt;Hi, thank you for taking the time to reply. I actually found out that because I am extracting the "ITREF" field using different methods, I can use the stats values command and it pulls the two together.&lt;/P&gt;

&lt;P&gt;I have included by solution on a separate post.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305747#M91805</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-07-13T12:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Stats Values and Count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305748#M91806</link>
      <description>&lt;P&gt;This was the working solution I cam up with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch
[ search `it_wmf(OutboundCall)`]
[ search `it_wmf(RequestReceived)` detail.responseMessage!=""]
| spath output=ITREF input=detail.responseMessage path=itRef
| spath output=given input=detail.responseMessage path=allGifts.isGivenAway
| rex field=request.detail.path "cases\/(?&amp;lt;ITREF&amp;gt;[^\W]+)\/"
| stats count values(auditSource) as auditSource values(auditType) as auditType values(given) as given by ITREF
| search given="true"
| where (auditType="OutboundCall" AND auditType="RequestReceived")
| stats dc(ITREF)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:18:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-Values-and-Count/m-p/305748#M91806</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-07-13T12:18:03Z</dc:date>
    </item>
  </channel>
</rss>

