<?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 do I get row number grouped by column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141924#M39338</link>
    <description>&lt;P&gt;Actually, worked it out.  the "by" clause goes after the "as" clause, which is not like usual Splunk syntax.  I would have expected an error rather than an empty column.  Anyway, thanks for the help.  For clarity, the correct search is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="the_index" earliest=-7month@month latest=@month  |  bucket _time span=1month | stats count by custName _time |  table  custName _time count | streamstats  as row count by custName | fields row *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not sure how to mark your answer as correct and give you points if you only gave it in a comment rather than as an answer, but thanks again!&lt;/P&gt;</description>
    <pubDate>Fri, 26 Sep 2014 17:13:13 GMT</pubDate>
    <dc:creator>leatherface</dc:creator>
    <dc:date>2014-09-26T17:13:13Z</dc:date>
    <item>
      <title>How do I get row number grouped by column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141921#M39335</link>
      <description>&lt;P&gt;I can add an absolute row number to my search results with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; streamstats count as row 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I would like the row count to group by other columns.  So in the example below, the row number groups by COL_A - each time the value of COL_A changes, the row number (ROW column) resets to 1 again&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ROW | COL_A | COL_B

---------------------
1   | ABC   | 123    
2   | ABC   | 456
3   | ABC   | 789
1   | DEF   | 123
2   | DEF   | 456
1   | GHI   | 789
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas?&lt;BR /&gt;
Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:42:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141921#M39335</guid>
      <dc:creator>leatherface</dc:creator>
      <dc:date>2020-09-28T17:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get row number grouped by column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141922#M39336</link>
      <description>&lt;P&gt;YOu are almost there. Just add a "by COL_A" in you streamstats command.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Sep 2014 13:46:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141922#M39336</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-09-26T13:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get row number grouped by column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141923#M39337</link>
      <description>&lt;P&gt;Streamstats works for me if I don't have a "by" clause, but as soon as I add the "by", the column has no values.  My search is trying to create a set of row numbers per custName, with the count column being the number of records for that customer in the month:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="the_index" earliest=-7month@month latest=@month  |  bucket _time span=1month | stats count by custName _time |  table  custName _time count | streamstats count by custName  as row | fields row *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What stupid mistake am I making?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Sep 2014 16:49:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141923#M39337</guid>
      <dc:creator>leatherface</dc:creator>
      <dc:date>2014-09-26T16:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get row number grouped by column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141924#M39338</link>
      <description>&lt;P&gt;Actually, worked it out.  the "by" clause goes after the "as" clause, which is not like usual Splunk syntax.  I would have expected an error rather than an empty column.  Anyway, thanks for the help.  For clarity, the correct search is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="the_index" earliest=-7month@month latest=@month  |  bucket _time span=1month | stats count by custName _time |  table  custName _time count | streamstats  as row count by custName | fields row *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not sure how to mark your answer as correct and give you points if you only gave it in a comment rather than as an answer, but thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Sep 2014 17:13:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141924#M39338</guid>
      <dc:creator>leatherface</dc:creator>
      <dc:date>2014-09-26T17:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get row number grouped by column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141925#M39339</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;index="the_index" earliest=-7month@month latest=@month | bucket _time span=1month | stats count by custName _time | table custName _time count | streamstats count as row by custName| fields row * &lt;/P&gt;</description>
      <pubDate>Fri, 26 Sep 2014 17:13:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-row-number-grouped-by-column/m-p/141925#M39339</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-09-26T17:13:39Z</dc:date>
    </item>
  </channel>
</rss>

