<?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: Multivalue stats in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546866#M5530</link>
    <description>&lt;P&gt;I don't understand why you are summing a count.&amp;nbsp; The sum should be the same as the count from the first stats.&lt;/P&gt;&lt;P&gt;I recommend avoiding the appendcols command unless you are guaranteed to get the same number of results as on the main search.&lt;/P&gt;&lt;P&gt;The stats command can perform multiple calculations so there's no need for appendcols.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index_1
| stats count(App) AS "Application Count", list(App) as Applications, count(Developer) as "Developer Count" by Department
| table Department "Application Count" Applications "Developer Count"&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 06 Apr 2021 12:42:46 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-04-06T12:42:46Z</dc:date>
    <item>
      <title>Multivalue stats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546861#M5529</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have got this SPL to perform what I was looking for but want to know if there is any more elegant way of achieving the same, possibly using just one stats command:&lt;BR /&gt;&lt;BR /&gt;index=index_1&lt;BR /&gt;| stats count(App) AS ACNT by Department&lt;BR /&gt;| stats sum(ACNT) as "Application Count" by Department | sort Department&lt;BR /&gt;| appendcols [search index=index_1 | dedup App | stats list(App) as Applications by Department | sort Department]&lt;BR /&gt;| appendcols [search index=index_1 | dedup Developer | stats count(Developer) as "Developer Count" by Department | sort Department]&lt;BR /&gt;| rename Department as Department&lt;BR /&gt;| table Department "Application Count" Applications "Developer Count"&lt;BR /&gt;&lt;BR /&gt;Expected output in attach&lt;BR /&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 12:27:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546861#M5529</guid>
      <dc:creator>me74fhfd</dc:creator>
      <dc:date>2021-04-06T12:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue stats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546866#M5530</link>
      <description>&lt;P&gt;I don't understand why you are summing a count.&amp;nbsp; The sum should be the same as the count from the first stats.&lt;/P&gt;&lt;P&gt;I recommend avoiding the appendcols command unless you are guaranteed to get the same number of results as on the main search.&lt;/P&gt;&lt;P&gt;The stats command can perform multiple calculations so there's no need for appendcols.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index_1
| stats count(App) AS "Application Count", list(App) as Applications, count(Developer) as "Developer Count" by Department
| table Department "Application Count" Applications "Developer Count"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Apr 2021 12:42:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546866#M5530</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-04-06T12:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue stats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546880#M5533</link>
      <description>&lt;P&gt;Thats a good call for SUM, thanks for that. Overall, provided SPL does not work because before doing "stats list(App)" dedup has to be applied but only for that calculation not for the whole data set, or atleast duplicates in multivalue field to be removed later. Same for Developer field with exception that performing dedup before stats line wont work because its applies to this field only. Basically fact that I have to perform dedup to these 2 calculations and not affecting the whole set is stopping to execute spl you have provided.&lt;BR /&gt;&lt;BR /&gt;Updated SPL from my side looks like this now:&lt;BR /&gt;&lt;BR /&gt;index=index_1 | stats count(Apps) AS "Application Count" by Department | sort Department | appendcols [search index=index_1 | dedup Apps | stats list(Apps) as Applications by Department | sort Department] | appendcols [search index=index_1 | dedup Developer | stats count(Developer) as "Developer Count" by Department | sort Department] | table Department "Application Count" Applications "Developer Count"&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 14:33:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546880#M5533</guid>
      <dc:creator>me74fhfd</dc:creator>
      <dc:date>2021-04-06T14:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue stats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546881#M5534</link>
      <description>&lt;P&gt;To avoid duplicates, use &lt;FONT face="courier new,courier"&gt;values(foo)&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;list(foo)&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;distinct_count(foo)&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;count(foo)&lt;/FONT&gt; in the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index_1
| stats count(App) AS "Application Count", values(App) as Applications, dc(Developer) as "Developer Count" by Department
| table Department "Application Count" Applications "Developer Count"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Apr 2021 14:44:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Multivalue-stats/m-p/546881#M5534</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-04-06T14:44:51Z</dc:date>
    </item>
  </channel>
</rss>

