<?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: Aggregate only some results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-only-some-results/m-p/571984#M199318</link>
    <description>&lt;P&gt;Seems to produce the same results&amp;nbsp; although no offence but I since those temporary fields are getting quite huge I'd not call that nicer &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But it's an interesting approach. I keep forgetting about eventstats. Thanks for the insight!&lt;/P&gt;</description>
    <pubDate>Fri, 22 Oct 2021 11:19:30 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-10-22T11:19:30Z</dc:date>
    <item>
      <title>Aggregate only some results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-only-some-results/m-p/571960#M199309</link>
      <description>&lt;P&gt;I'll probably find my solution finally but if someone has something at hand, I'd be grateful for sharing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have some results. Let's say they are like this:&lt;/P&gt;&lt;TABLE border="1" width="56.25%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Count&lt;/TD&gt;&lt;TD width="25%"&gt;FieldA&lt;/TD&gt;&lt;TD width="25%"&gt;FieldB&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;11&lt;/TD&gt;&lt;TD width="25%"&gt;a&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;12&lt;/TD&gt;&lt;TD width="25%"&gt;b&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;34&lt;/TD&gt;&lt;TD width="25%"&gt;c&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;54&lt;/TD&gt;&lt;TD width="25%"&gt;d&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;462&lt;/TD&gt;&lt;TD width="25%"&gt;e&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;0&lt;/TD&gt;&lt;TD width="25%"&gt;f&lt;/TD&gt;&lt;TD width="25%"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;12&lt;/TD&gt;&lt;TD width="25%"&gt;g&lt;/TD&gt;&lt;TD width="25%"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;4&lt;/TD&gt;&lt;TD width="25%"&gt;h&lt;/TD&gt;&lt;TD width="25%"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like the values from the count column summed up but only for the events that have FieldB defined. For the rest, I want them lest split by FieldA. For those summed up I want the FieldA to be aggregated into a multivalue field&lt;/P&gt;&lt;P&gt;So effectively the output should be like&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;Count&lt;/TD&gt;&lt;TD width="25%"&gt;FieldA&lt;/TD&gt;&lt;TD width="25%"&gt;FieldB&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;11&lt;/TD&gt;&lt;TD width="25%"&gt;a&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;12&lt;/TD&gt;&lt;TD width="25%"&gt;b&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;88&lt;/TD&gt;&lt;TD width="25%"&gt;c&lt;BR /&gt;d&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;462&lt;/TD&gt;&lt;TD width="25%"&gt;e&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;16&lt;/TD&gt;&lt;TD width="25%"&gt;f&lt;BR /&gt;g&lt;BR /&gt;h&lt;/TD&gt;&lt;TD width="25%"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK. I think I can get it done by adding another column being created conditionally either from fieldA or fieldB, then aggregating by this field. Something like this:&lt;/P&gt;&lt;PRE&gt;&amp;lt;initial search&amp;gt;
| eval tempfield=if(isnull(fieldB),"fieldA-".fieldA,"fieldB-".fieldB)
| stats sum(count) as count values(fieldA) as fieldA values(fieldB) as fieldB by tempfield
| fields - tempfield&lt;/PRE&gt;&lt;P&gt;Any nicer way?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 07:56:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-only-some-results/m-p/571960#M199309</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-22T07:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate only some results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-only-some-results/m-p/571980#M199315</link>
      <description>&lt;P&gt;Not sure if this is nicer, but would this work?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats sum(Count) as AllCount values(FieldA) as AllFieldA by FieldB
| eval Count=if(isnull(FieldB),Count,AllCount)
| eval FieldA=if(isnull(FieldB),FieldA,AllFieldA)
| dedup FieldA
| table Count FieldA FieldB&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Oct 2021 10:22:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-only-some-results/m-p/571980#M199315</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-22T10:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate only some results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-only-some-results/m-p/571984#M199318</link>
      <description>&lt;P&gt;Seems to produce the same results&amp;nbsp; although no offence but I since those temporary fields are getting quite huge I'd not call that nicer &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But it's an interesting approach. I keep forgetting about eventstats. Thanks for the insight!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 11:19:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-only-some-results/m-p/571984#M199318</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-22T11:19:30Z</dc:date>
    </item>
  </channel>
</rss>

