<?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: Order by and group by in splunk to sort event columns in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Order-by-and-group-by-in-splunk-to-sort-event-columns/m-p/377054#M41110</link>
    <description>&lt;P&gt;Not 100% sure what you're after but Sstats and sort is all you should need. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats values(FIELD_TEXT) AS FIELD_TEXT by GROUP_ID Field1
| sort Field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;GROUP_ID Field1 FIELD_TEXT
A        0      Select
B        0      name
A        2      from
A        4      table2
B        4      table
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If thats not what you need, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  stats list(FIELD_TEXT) as FIELD_TEXT list(Field1) as Field1 by GROUP_ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will give you something like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;GROUP_ID    FIELD_TEXT      Field1
A           Select from table2  0 2 4
B            name table     0 4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you're coming from a SQL back ground this document may help you adjust to Splunk: &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/7.0.3/SearchReference/SQLtoSplunk"&gt;http://docs.splunk.com/Documentation/SplunkCloud/7.0.3/SearchReference/SQLtoSplunk&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Jul 2018 09:06:39 GMT</pubDate>
    <dc:creator>jplumsdaine22</dc:creator>
    <dc:date>2018-07-27T09:06:39Z</dc:date>
    <item>
      <title>Order by and group by in splunk to sort event columns</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Order-by-and-group-by-in-splunk-to-sort-event-columns/m-p/377053#M41109</link>
      <description>&lt;P&gt;2018/17/25 19:37:27 Field1="0" GROUP_ID="A" FIELD_TEXT="Select"&lt;BR /&gt;
2018/17/25 10:30:17 Field1="0"GROUP_ID="B" FIELD_TEXT="name"&lt;BR /&gt;
2018/17/25 06:9:00 Field1="2" GROUP_ID="A"FIELD_TEXT="from "&lt;BR /&gt;
2018/17/25 00:00:00 Field1="4" GROUP_ID="B"FIELD_TEXT="table"&lt;BR /&gt;
2018/17/25 00:00:00 Field1="4" GROUP_ID="A"FIELD_TEXT="table2"&lt;/P&gt;

&lt;P&gt;Required o/p&lt;BR /&gt;
GROUP_ID             Field_TEXT &lt;BR /&gt;
A                               SELECT from table2&lt;BR /&gt;
B                                     Name table&lt;/P&gt;

&lt;P&gt;I wanted to display the FIELD_TEXT value order by Field1 and group by group id&lt;BR /&gt;
CAn any one suggest me, how can I achieve this &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:39:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Order-by-and-group-by-in-splunk-to-sort-event-columns/m-p/377053#M41109</guid>
      <dc:creator>swetar</dc:creator>
      <dc:date>2020-09-29T20:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Order by and group by in splunk to sort event columns</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Order-by-and-group-by-in-splunk-to-sort-event-columns/m-p/377054#M41110</link>
      <description>&lt;P&gt;Not 100% sure what you're after but Sstats and sort is all you should need. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats values(FIELD_TEXT) AS FIELD_TEXT by GROUP_ID Field1
| sort Field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;GROUP_ID Field1 FIELD_TEXT
A        0      Select
B        0      name
A        2      from
A        4      table2
B        4      table
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If thats not what you need, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  stats list(FIELD_TEXT) as FIELD_TEXT list(Field1) as Field1 by GROUP_ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will give you something like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;GROUP_ID    FIELD_TEXT      Field1
A           Select from table2  0 2 4
B            name table     0 4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you're coming from a SQL back ground this document may help you adjust to Splunk: &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/7.0.3/SearchReference/SQLtoSplunk"&gt;http://docs.splunk.com/Documentation/SplunkCloud/7.0.3/SearchReference/SQLtoSplunk&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2018 09:06:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Order-by-and-group-by-in-splunk-to-sort-event-columns/m-p/377054#M41110</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2018-07-27T09:06:39Z</dc:date>
    </item>
  </channel>
</rss>

