<?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 get sum stats from pair of values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472249#M132870</link>
    <description>&lt;P&gt;It works !!! Thanks a lot !! I knew it was easy but sometimes I'm lost with all that commands !! Thank you !&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2019 18:50:20 GMT</pubDate>
    <dc:creator>maellebrown</dc:creator>
    <dc:date>2019-09-05T18:50:20Z</dc:date>
    <item>
      <title>How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472245#M132866</link>
      <description>&lt;P&gt;Hi! &lt;BR /&gt;
I am looking for help for, I think, a simple statistic but I can't figure out how to do this simply. &lt;BR /&gt;
Here's an example of my data : &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;1. Customer1=A,  Customer2=B&lt;BR /&gt;
2. Customer1=A, Customer2=C&lt;BR /&gt;
3. Customer1=B, Customer2=A&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;and I want spunk to count the number of event by pair of customer, like :&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Pair=AB, count=2&lt;BR /&gt;
Pair=AC, count=1&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I'm sure spunk can do that really easily but all I can do is that and it's pretty ugly and duplicates the result :&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;eval pair1=Customer1. " / ". Customer2&lt;BR /&gt;
eval pair2=Customer2. " / ". Customer1&lt;BR /&gt;
eval pair=mvappend(pair1, pair2)&lt;BR /&gt;
stats count by pair&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Please help!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 19:16:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472245#M132866</guid>
      <dc:creator>maellebrown</dc:creator>
      <dc:date>2019-09-04T19:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472246#M132867</link>
      <description>&lt;P&gt;Greetings @maellebrown,&lt;/P&gt;

&lt;P&gt;Please try this run-anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;           | makeresults | eval Customer1="A", Customer2="B"
| append [ | makeresults | eval Customer1="A", Customer2="C" ]
| append [ | makeresults | eval Customer1="B", Customer2="A" ]
| eval Customer1_sort=if(Customer1&amp;lt;Customer2,Customer1,Customer2),
       Customer2_sort=if(Customer1&amp;lt;Customer2,Customer2,Customer1)
| eval CustomerPair  = Customer1_sort . " / " . Customer2_sort
| stats count by CustomerPair
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CustomerPair    count
A / B            2
A / C            1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 21:53:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472246#M132867</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2019-09-04T21:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472247#M132868</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving fields Customer1 and Customer2
| eval CustomerPair=mvsort(split("/".Customer1."##/".Customer2,"##"))
| nomv CustomerPair
| stats count by CustomerPair
| eval CustomerPair=replace(CustomerPair,"^\/(.+)","\1")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 13:38:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472247#M132868</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-09-05T13:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472248#M132869</link>
      <description>&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search
| rename COMMENT as "stats the first time to get ordered pairs"
| stats count as count1 by Customer1 Customer2

| rename COMMENT as "sort customer names into order and then combine prior stats"
| eval CustomerA=if(Customer1&amp;lt;=Customer2,Customer1,Customer2)
| eval CustomerB=if(Customer1&amp;lt;=Customer2,Customer2,Customer1)
| stats sum(count1) as count by CustomerA CustomerB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gives you &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CustomerA CustomerB count
A         B         2
A         C         1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 14:38:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472248#M132869</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2019-09-05T14:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472249#M132870</link>
      <description>&lt;P&gt;It works !!! Thanks a lot !! I knew it was easy but sometimes I'm lost with all that commands !! Thank you !&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 18:50:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472249#M132870</guid>
      <dc:creator>maellebrown</dc:creator>
      <dc:date>2019-09-05T18:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472250#M132871</link>
      <description>&lt;P&gt;Yes thank you ! &lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 18:51:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472250#M132871</guid>
      <dc:creator>maellebrown</dc:creator>
      <dc:date>2019-09-05T18:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472251#M132872</link>
      <description>&lt;P&gt;Glad to hear it - you're welcome! Thank you for marking the answer for us and anyone who comes across this in the future.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 18:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472251#M132872</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2019-09-05T18:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get sum stats from pair of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472252#M132873</link>
      <description>&lt;P&gt;Thanks for the answer ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 19:04:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-sum-stats-from-pair-of-values/m-p/472252#M132873</guid>
      <dc:creator>maellebrown</dc:creator>
      <dc:date>2019-09-05T19:04:37Z</dc:date>
    </item>
  </channel>
</rss>

