<?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 sort and group data by day and ID? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357451#M174838</link>
    <description>&lt;P&gt;Thanks. I forgot to put Names as the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(name) as Names (...)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;because I would like to have the sum of each unique value of it in: list(count).&lt;/P&gt;</description>
    <pubDate>Mon, 01 May 2017 21:48:10 GMT</pubDate>
    <dc:creator>Yaichael</dc:creator>
    <dc:date>2017-05-01T21:48:10Z</dc:date>
    <item>
      <title>How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357447#M174834</link>
      <description>&lt;P&gt;I would like to display the events as the following:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2849i69AC4811F898FA6E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;where it is grouped and sorted by day, and sorted by ID numerically (after converting from string to number). I have only managed to group and sort the events by day, but I haven't reached the desired result.&lt;/P&gt;

&lt;P&gt;Any better approach?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 20:47:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357447#M174834</guid>
      <dc:creator>Yaichael</dc:creator>
      <dc:date>2017-05-01T20:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357448#M174835</link>
      <description>&lt;P&gt;I'm not sure if the two level grouping is possible (group by Date and Group by num, kind of excel type merging/grouping). You may be able to achieve this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Dates ID Names Count total
Date1 num1 ABC 10 100
           DEF 90
Date1 num2 XYZ 20 50
           PQR 30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you can post your current query, I can update it to provide above format&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 21:02:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357448#M174835</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-05-01T21:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357449#M174836</link>
      <description>&lt;P&gt;Thanks for the reply, someoni2.&lt;/P&gt;

&lt;P&gt;Here's my current query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(...)
| rex mode=sed field=amount "s/[^\d\.-]//g"
| bucket _time span=1d
| stats count by _time id name amount
| rename id as IDs
| stats values(_time) as Dates values(name) as Names list(count) as "Count by Name" sum(amount) AS total by IDs
| eval Total = "$".total
| rename Total as "Total Amount"
| fields - total
| sort - Dates
| convert timeformat="%m/%d/%Y" ctime(Dates)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 May 2017 21:21:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357449#M174836</guid>
      <dc:creator>Yaichael</dc:creator>
      <dc:date>2017-05-01T21:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357450#M174837</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(...)
 | rex mode=sed field=amount "s/[^\d\.-]//g"
 | bucket _time span=1d
 | stats count by _time id name amount
 | rename id as IDs
 | stats list(name) as Names list(count) as "Count by Name" sum(amount) as "Total Amount" by _time IDs
 | eval "Total Amount" = "$".'Total Amount'
 | eval Date=strftime(_time,"%m/%d/%Y") | fields - _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 May 2017 21:36:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357450#M174837</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-05-01T21:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357451#M174838</link>
      <description>&lt;P&gt;Thanks. I forgot to put Names as the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(name) as Names (...)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;because I would like to have the sum of each unique value of it in: list(count).&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 21:48:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357451#M174838</guid>
      <dc:creator>Yaichael</dc:creator>
      <dc:date>2017-05-01T21:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357452#M174839</link>
      <description>&lt;P&gt;Something is very strange about your query.  Why are you grouping by amount?  Is the amount really always $1?  If so, you wouldn't &lt;STRONG&gt;have&lt;/STRONG&gt; to group by it. If &lt;STRONG&gt;not&lt;/STRONG&gt;, then you probably wouldn't &lt;STRONG&gt;want&lt;/STRONG&gt; to group by it.&lt;/P&gt;

&lt;P&gt;This is similar to one strategy that I use...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed field=amount "s/[^\d\.-]//g"
| bucket _time span=1d
| stats count as myCount sum(amount) as myAmount by _time id name
| rename id as IDs
| eval NameCount = name." ----- ".myCount
| stats values(NameCount) as NameCount, sum(myCount) as Count, sum(myAmount) as Total by _time IDs    
| rename COMMENT as "Tne above puts Name and the related Count together line by line into a single multivalue field."

| eval Total = "$".ROUND(Total,2)
| rename Total as "Total_Amount"
| rename NameCount as "Name_____Count_By_Name"
| eval Dates = _time
| sort 0 Dates
| convert timeformat="%m/%d/%Y" ctime(Dates)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 May 2017 23:57:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357452#M174839</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-01T23:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357453#M174840</link>
      <description>&lt;P&gt;Thanks for the help.&lt;/P&gt;

&lt;P&gt;How can I split the total amount by counted names?&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 16:34:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357453#M174840</guid>
      <dc:creator>Yaichael</dc:creator>
      <dc:date>2017-05-02T16:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357454#M174841</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;(...)
| rex mode=sed field=amount "s/[^\d\.-]//g"
| bucket _time span=1d
| stats count as myCount sum(amount) as myAmount by _time id name
| rename id as IDs
| eval NameCount = name." ----- ".myCount
| eval TotalCount = name." ----- $".myAmount
| stats values(NameCount) as NameCount, sum(myCount) as Count, values(TotalCount) as TotalCount , sum(myAmount) as Total by _time IDs
| eval Total = "$".ROUND(Total,2)
| rename Total as "Total Amount" TotalCount as "Amount by Name"
| rename NameCount as "Names ----- Count by Name"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2017 17:59:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357454#M174841</guid>
      <dc:creator>Yaichael</dc:creator>
      <dc:date>2017-05-02T17:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort and group data by day and ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357455#M174842</link>
      <description>&lt;P&gt;Yes, that should work.  you might want to format the Amount by name...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval TotalCount = name." ----- $".Round(myAmount,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would tend to put each count and amount into a single field, and align them&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(...)
| rex mode=sed field=amount "s/[^\d\.-]//g"
| bucket _time span=1d
| stats count as myCount sum(amount) as myAmount by _time id name
| eval namelen=len(name), amtlen=len(tostr(round(myAmount,2))), countlen=len(tostr(count))
| eventstats max(namelen) as maxname, max(amtlen) as maxamt,max(countlen) as maxcount
| eval biglongspacestring="                             "
| eval namespacer = substr(biglongspacestring,1,1+maxname-namelen)
| eval amtspacer = substr(biglongspacestring,1,1+maxamt-amtlen)
| eval countspacer = substr(biglongspacestring,1,1+maxcount-countlen)
| eval NameCount = name." ".namespacer." ".myCount." ".countspacer.amtspacer." $".tostr(round(myAmount,2))
| stats values(NameCount) as NameCount, sum(myCount) as Count, sum(myAmount) as Total by _time IDs
| eval Total = "$".round(Total,2)
| rename Total as "Total Amount" 
| rename NameCount as "Per Name-----Count-----Amount"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2017 18:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-and-group-data-by-day-and-ID/m-p/357455#M174842</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-02T18:43:45Z</dc:date>
    </item>
  </channel>
</rss>

