<?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 do a stats count by on only some array elements? in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628660#M15231</link>
    <description>&lt;P&gt;Hey everyone. I am trying to do a stats count by items{}.description, items{}.price but I'd like to filter out some of the items. In this example, I'd like to include "description one" and "description two", but not "description three".&amp;nbsp; In the real situation there is many more that I'd like to include and to exclude.&lt;BR /&gt;&lt;BR /&gt;Is this possible?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;"time": "01:01:01",
"items": [
    {
      "description": "description one",
      "price": "$220"
    },
    {
      "description": "description two",
      "price": "$10"
    },
    {
      "description": "description three",
      "price": "$50"
    }
]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Jan 2023 19:37:34 GMT</pubDate>
    <dc:creator>thomas_nguyen</dc:creator>
    <dc:date>2023-01-27T19:37:34Z</dc:date>
    <item>
      <title>How to do a stats count by on only some array elements?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628660#M15231</link>
      <description>&lt;P&gt;Hey everyone. I am trying to do a stats count by items{}.description, items{}.price but I'd like to filter out some of the items. In this example, I'd like to include "description one" and "description two", but not "description three".&amp;nbsp; In the real situation there is many more that I'd like to include and to exclude.&lt;BR /&gt;&lt;BR /&gt;Is this possible?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;"time": "01:01:01",
"items": [
    {
      "description": "description one",
      "price": "$220"
    },
    {
      "description": "description two",
      "price": "$10"
    },
    {
      "description": "description three",
      "price": "$50"
    }
]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 19:37:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628660#M15231</guid>
      <dc:creator>thomas_nguyen</dc:creator>
      <dc:date>2023-01-27T19:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a stats count by on only some array elements?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628689#M15233</link>
      <description>&lt;P&gt;Try extracting the items from the collection with spath, then mvexpand the multi-value field, then extract the next level down, and filter the values you want to keep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath items{} output=items
| mvexpand items
| spath input=items
| where description IN ("description one", "description two")
| stats count by description, price&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2023 09:00:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628689#M15233</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-28T09:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a stats count by on only some array elements?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628691#M15235</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;thank you so much. That worked. I did have to tweak it slightly but I was able to get what I was looking for.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath output=items path=items{}
| mvexpand items
| spath input=items
| where description IN ("description one", "description two")
| stats count by description, price&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 27 Jan 2023 23:39:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628691#M15235</guid>
      <dc:creator>thomas_nguyen</dc:creator>
      <dc:date>2023-01-27T23:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a stats count by on only some array elements?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628705#M15240</link>
      <description>&lt;P&gt;Thanks - I updated the solution (a typo on my part)&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2023 09:02:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-do-a-stats-count-by-on-only-some-array-elements/m-p/628705#M15240</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-01-28T09:02:33Z</dc:date>
    </item>
  </channel>
</rss>

