<?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: How to aggregate results by elements in the array, and sort them by ratio in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-aggregate-results-by-elements-in-the-array-and-sort-them/m-p/752792#M119507</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/312487"&gt;@karol&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use spath and mvexpand on your field.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath input=attributes
| mvexpand attributes
| eval true_count=if(attributes="true", 1, 0), false_count=if(attributes="false", 1, 0)
| stats sum(true_count) as true_count sum(false_count) as false_count by name
| eval percentage=round((true_count / (true_count + false_count)) * 100, 2)
| sort - percentage
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="demo12.JPG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/40185iC29AD0DDB95C73F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="demo12.JPG" alt="demo12.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 08 Sep 2025 04:33:57 GMT</pubDate>
    <dc:creator>PrewinThomas</dc:creator>
    <dc:date>2025-09-08T04:33:57Z</dc:date>
    <item>
      <title>How to aggregate results by elements in the array, and sort them by ratio</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-aggregate-results-by-elements-in-the-array-and-sort-them/m-p/752790#M119506</link>
      <description>&lt;P&gt;I got my data stream in a following format:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[
    {
        "name": "event 1"
        "attributes": [false, true, true],
    },
    {
        "name": "event 2"
        "attributes": [false, false, true],
    }
]&lt;/LI-CODE&gt;&lt;P&gt;I want to output them sorting by a ratio of `true` to `false` values in the array:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;name| true count | false count | percentage

event 1 | 2 | 1 | 66.67%
event 2 | 1 | 2 | 33.33%&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 04:07:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-aggregate-results-by-elements-in-the-array-and-sort-them/m-p/752790#M119506</guid>
      <dc:creator>karol</dc:creator>
      <dc:date>2025-09-08T04:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate results by elements in the array, and sort them by ratio</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-aggregate-results-by-elements-in-the-array-and-sort-them/m-p/752792#M119507</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/312487"&gt;@karol&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use spath and mvexpand on your field.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath input=attributes
| mvexpand attributes
| eval true_count=if(attributes="true", 1, 0), false_count=if(attributes="false", 1, 0)
| stats sum(true_count) as true_count sum(false_count) as false_count by name
| eval percentage=round((true_count / (true_count + false_count)) * 100, 2)
| sort - percentage
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="demo12.JPG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/40185iC29AD0DDB95C73F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="demo12.JPG" alt="demo12.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 04:33:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-aggregate-results-by-elements-in-the-array-and-sort-them/m-p/752792#M119507</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-09-08T04:33:57Z</dc:date>
    </item>
  </channel>
</rss>

