<?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 How to drop extra fields while maintaining groupby? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-drop-extra-fields-while-maintaining-groupby/m-p/555533#M157703</link>
    <description>&lt;P&gt;To groupby? &amp;nbsp;Or not to groupby? &amp;nbsp;That is the question. (Not really. &amp;nbsp;The question arises because trellis splitby seems to depend on an invisible groupby register.)&lt;/P&gt;&lt;P&gt;Take the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=10
| eval value = "value" . random() % 3
| stats count by value
| eventstats sum(count) as total
| eval ratio = count / total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to visualize ratio as single value in trellis, I can add `| fields - total count` in the end.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="groupby.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14601iF2D1A5CAD9CB5CA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="groupby.png" alt="groupby.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But if there are many intermediate variables, it gets tedious to list them for dropping. &amp;nbsp;I thought `table value ratio` would be simpler, as statistics table is exactly the same, but SPL's invisible hand prevents splitby from seeing the original groupby field, so I get weird output like&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="groupbynot.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14603i9FC52B173E4E8015/image-size/medium?v=v2&amp;amp;px=400" role="button" title="groupbynot.png" alt="groupbynot.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I can avoid tedious `fields -` listing by doing another stats with groupby, e.g., `stats values(ratio) as ratio by value`.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="groupbydouble.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14604i0D3C90223403FA7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="groupbydouble.png" alt="groupbydouble.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;But I feel silly to do a useless calculation. &amp;nbsp;Is there a simpler way to preserve groupby register without the tedious listing?&lt;/P&gt;</description>
    <pubDate>Sat, 12 Jun 2021 00:43:00 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2021-06-12T00:43:00Z</dc:date>
    <item>
      <title>How to drop extra fields while maintaining groupby?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-drop-extra-fields-while-maintaining-groupby/m-p/555533#M157703</link>
      <description>&lt;P&gt;To groupby? &amp;nbsp;Or not to groupby? &amp;nbsp;That is the question. (Not really. &amp;nbsp;The question arises because trellis splitby seems to depend on an invisible groupby register.)&lt;/P&gt;&lt;P&gt;Take the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=10
| eval value = "value" . random() % 3
| stats count by value
| eventstats sum(count) as total
| eval ratio = count / total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to visualize ratio as single value in trellis, I can add `| fields - total count` in the end.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="groupby.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14601iF2D1A5CAD9CB5CA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="groupby.png" alt="groupby.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But if there are many intermediate variables, it gets tedious to list them for dropping. &amp;nbsp;I thought `table value ratio` would be simpler, as statistics table is exactly the same, but SPL's invisible hand prevents splitby from seeing the original groupby field, so I get weird output like&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="groupbynot.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14603i9FC52B173E4E8015/image-size/medium?v=v2&amp;amp;px=400" role="button" title="groupbynot.png" alt="groupbynot.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I can avoid tedious `fields -` listing by doing another stats with groupby, e.g., `stats values(ratio) as ratio by value`.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="groupbydouble.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14604i0D3C90223403FA7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="groupbydouble.png" alt="groupbydouble.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;But I feel silly to do a useless calculation. &amp;nbsp;Is there a simpler way to preserve groupby register without the tedious listing?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 00:43:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-drop-extra-fields-while-maintaining-groupby/m-p/555533#M157703</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-06-12T00:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to drop extra fields while maintaining groupby?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-drop-extra-fields-while-maintaining-groupby/m-p/555534#M157704</link>
      <description>&lt;P&gt;I just realize that I can carefully name intermediate variables so I can drop them with wildcard. &amp;nbsp;But is there any SPL answer to the original question?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 00:45:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-drop-extra-fields-while-maintaining-groupby/m-p/555534#M157704</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-06-12T00:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to drop extra fields while maintaining groupby?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-drop-extra-fields-while-maintaining-groupby/m-p/757531#M243187</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;is there any SPL answer to the original question?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The answer, it turns out, is yes. &amp;nbsp;Instead of listing intermediate field names for exclusion, name all intermediate fields to be "hidden", i.e., start with underscore _. &amp;nbsp;The above search can be written as&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=10
| eval value = "value" . random() % 3
| stats count as _count by value
| eventstats sum(_count) as _total
| eval ratio = _count / _total&lt;/LI-CODE&gt;&lt;P&gt;Splunk visualization will conveniently ignore hidden fields.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-01-21 at 12.49.26 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/41222iCC2EF31D1C5C5DF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2026-01-21 at 12.49.26 PM.png" alt="Screenshot 2026-01-21 at 12.49.26 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This writing has more elaborate use cases of this technique:&amp;nbsp;&lt;A href="https://whackyhack.wordpress.com/2025/03/11/up-your-textual-viz-with-splunk/" target="_blank" rel="noopener"&gt;Up Your Textual Viz with Splunk&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jan 2026 20:58:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-drop-extra-fields-while-maintaining-groupby/m-p/757531#M243187</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2026-01-21T20:58:48Z</dc:date>
    </item>
  </channel>
</rss>

