<?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: Group by two or many fields fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331420#M98605</link>
    <description>&lt;P&gt;However, you might want to consider this format instead - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|chart sum(Count) over Book by Location
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...which gives this result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Book      Boston    Dallas    NYC       
book1     32        13        3         
book2     51        15        5         
book3     32        13        3       
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Feb 2017 20:00:39 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-02-28T20:00:39Z</dc:date>
    <item>
      <title>Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331415#M98600</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;This is my data :&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://zupimages.net/up/17/09/xr0a.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;I want to group result by two fields like that :&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://zupimages.net/up/17/09/9mpv.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;I follow the instructions on this topic &lt;A href="https://answers.splunk.com/answers/186874/how-to-use-group-by-with-two-fields-1.html"&gt;link text&lt;/A&gt; , but I did not get the fields grouped as I want. They are grouped but I don't have the count for each row.&lt;/P&gt;

&lt;P&gt;Can anyone help me?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 18:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331415#M98600</guid>
      <dc:creator>Naaba</dc:creator>
      <dc:date>2017-02-28T18:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331416#M98601</link>
      <description>&lt;P&gt;this is the link &lt;A href="https://answers.splunk.com/answers/186874/how-to-use-group-by-with-two-fields-1.html"&gt;https://answers.splunk.com/answers/186874/how-to-use-group-by-with-two-fields-1.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 18:35:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331416#M98601</guid>
      <dc:creator>Naaba</dc:creator>
      <dc:date>2017-02-28T18:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331417#M98602</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;try the following.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your-base-search | stats count by location, book
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 18:44:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331417#M98602</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2017-02-28T18:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331418#M98603</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search giving fields Location, Book and Count 
| stats sum(Count) as Count by Location Book
| stats list(Book) as Book list(Count) as Count by Location
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 19:29:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331418#M98603</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-28T19:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331419#M98604</link>
      <description>&lt;P&gt;Your data actually IS grouped the way you want.  You just want to report it in such a way that the Location doesn't appear.  So, here's one way you can mask the RealLocation with a display "location" by checking to see if the RealLocation is the same as the prior record, using the autoregress function.&lt;/P&gt;

&lt;P&gt;This part just generates some test data-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval mydata = "NYC,book1,3 NYC,book2,5 NYC,book3,3 Boston,book1,32 Boston,book2,51 Boston,book3,32 Dallas,book1,13 Dallas,book3,13 Dallas,book2,15" 
|makemv mydata| mvexpand mydata |makemv delim="," mydata 
| eval Location=mvindex(mydata,0), Book=mvindex(mydata,1), Count=mvindex(mydata,2) 
| table Location, Book, Count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This part sorts it and masks the RealLocation &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| sort 0 Location, Book 
| autoregress Location 
| rename Location as RealLocation 
| eval Location=if(RealLocation==Location_p1,"-",RealLocation) 
| table Location Book Count RealLocation
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With these results&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Location Book   Count RealLocation
Boston   book1   32   Boston
-        book2   51   Boston
-        book3   32   Boston
Dallas   book1   13   Dallas
-        book2   15   Dallas
-        book3   13   Dallas
NYC      book1    3   NYC
-        book2    5   NYC
-        book3    3   NYC
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 19:56:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331419#M98604</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-28T19:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331420#M98605</link>
      <description>&lt;P&gt;However, you might want to consider this format instead - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|chart sum(Count) over Book by Location
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...which gives this result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Book      Boston    Dallas    NYC       
book1     32        13        3         
book2     51        15        5         
book3     32        13        3       
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 20:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331420#M98605</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-28T20:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331421#M98606</link>
      <description>&lt;P&gt;It tried this command but I have the same result&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://www.hostingpics.net/viewer.php?id=385099img1.jpg" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 08:33:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331421#M98606</guid>
      <dc:creator>Naaba</dc:creator>
      <dc:date>2017-03-01T08:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331422#M98607</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I tried your command but. The data are listed as I want but the count column is empty.&lt;BR /&gt;
Do you know why?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 08:36:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331422#M98607</guid>
      <dc:creator>Naaba</dc:creator>
      <dc:date>2017-03-01T08:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331423#M98608</link>
      <description>&lt;P&gt;I made a mistake in my command.&lt;BR /&gt;
It worked. thanks for your help&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 08:40:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331423#M98608</guid>
      <dc:creator>Naaba</dc:creator>
      <dc:date>2017-03-01T08:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Group by two or many fields fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331424#M98609</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thanks for your help.&lt;BR /&gt;
This worked for me :&lt;/P&gt;

&lt;P&gt;| stats sum(Count) as Count by Location Book&lt;BR /&gt;
 | stats list(Book) as Book list(Count) as Count by Location&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 08:57:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-by-two-or-many-fields-fields/m-p/331424#M98609</guid>
      <dc:creator>Naaba</dc:creator>
      <dc:date>2017-03-01T08:57:43Z</dc:date>
    </item>
  </channel>
</rss>

