<?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: Adding fields in stats command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-fields-in-stats-command/m-p/659952#M227831</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236500"&gt;@smanojkumar&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;after the BY cluse you should add only the fields to use for aggregation.&lt;/P&gt;&lt;P&gt;The other fields can be added to the stats command suing the values option.&lt;/P&gt;&lt;P&gt;So if you want to aggregate only for name and you want the other fields, you could use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats 
   count AS num 
   values(country) AS country
   values(state) AS state
   values(scope) AS scope
   values(event) AS event
   values(description) AS description
   BY name &lt;/LI-CODE&gt;&lt;P&gt;As you can read at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/StatsCommandOverview" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/StatsCommandOverview&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2023 08:59:37 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-10-06T08:59:37Z</dc:date>
    <item>
      <title>Adding fields in stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-fields-in-stats-command/m-p/659950#M227829</link>
      <description>&lt;P&gt;Hi Splunkers!&lt;BR /&gt;&amp;nbsp; &amp;nbsp;Good day!&lt;BR /&gt;&amp;nbsp; &amp;nbsp;I would like to add event and detection fields in stats command, after adding in stats command, I'm not getting the expected results. I need that fields as well but I should get the expected results,&lt;BR /&gt;&lt;BR /&gt;Old command&amp;nbsp;&lt;BR /&gt;| stats count as num by name country state scope&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Modified command&lt;BR /&gt;| stats count as num by name country state scope event description - giving me wrong results.&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance!&lt;BR /&gt;Manoj Kumar S&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 08:54:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-fields-in-stats-command/m-p/659950#M227829</guid>
      <dc:creator>smanojkumar</dc:creator>
      <dc:date>2023-10-06T08:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding fields in stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-fields-in-stats-command/m-p/659952#M227831</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236500"&gt;@smanojkumar&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;after the BY cluse you should add only the fields to use for aggregation.&lt;/P&gt;&lt;P&gt;The other fields can be added to the stats command suing the values option.&lt;/P&gt;&lt;P&gt;So if you want to aggregate only for name and you want the other fields, you could use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats 
   count AS num 
   values(country) AS country
   values(state) AS state
   values(scope) AS scope
   values(event) AS event
   values(description) AS description
   BY name &lt;/LI-CODE&gt;&lt;P&gt;As you can read at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/StatsCommandOverview" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/StatsCommandOverview&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 08:59:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-fields-in-stats-command/m-p/659952#M227831</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-10-06T08:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Adding fields in stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-fields-in-stats-command/m-p/659955#M227832</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&amp;nbsp; &amp;nbsp;It works, Thanks for your response!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 10:07:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-fields-in-stats-command/m-p/659955#M227832</guid>
      <dc:creator>smanojkumar</dc:creator>
      <dc:date>2023-10-06T10:07:35Z</dc:date>
    </item>
  </channel>
</rss>

