<?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: Get statistical distribution of multivalue entry in Splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistical-distribution-of-multivalue-entry-in/m-p/645622#M223534</link>
    <description>&lt;LI-CODE lang="markup"&gt;``` get all purchases ```
index=customer_data action=purchase
``` narrow down to purchases from our top 100 customers (based on purchase count) ```
[search index=customer_data action=purchase top limit=100 user_id | table user_id]
``` show type of products that each user purchased ```
| stats count, list(product_category) as product_category by user_id
| stats values(count) as total count by user_id product_category
| eval product_category=product_category."=".round(100*count/total,2)."%"
| stats values(product_category) as product_category by user_id
| eval product_category=mvjoin(product_category,", ")&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 03 Jun 2023 05:32:52 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2023-06-03T05:32:52Z</dc:date>
    <item>
      <title>How to get statistical distribution of multivalue entry in Splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistical-distribution-of-multivalue-entry-in/m-p/645616#M223530</link>
      <description>&lt;P&gt;I am starting with this query to show which types of products our top customers buy&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;LI-CODE lang="markup"&gt;``` get all purchases ```
index=customer_data action=purchase
``` narrow down to purchases from our top 100 customers (based on purchase count) ```
[search index=customer_data action=purchase top limit=100 user_id | table user_id]
``` show type of products that each user purchased ```
| stats count, list(product_category) by user_id&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will give some output like this:&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;LI-CODE lang="markup"&gt;user_id | values(product_category)
------------------------------------
1234 | clothing, clothing, clothing, food
2345 | electronics, electronics, food, food&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;I need one additional piece of information: the ratio of the product categories, for each user. I need this output instead. The format of the distributions is not important&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;LI-CODE lang="markup"&gt;user_id | values(product_category)
------------------------------------
1234 | clothing=75%, food=25%
2345 | electronics=50%, food=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;The best idea I have thus far is something like this:&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;LI-CODE lang="markup"&gt;``` get all purchases ```
index=customer_data action=purchase
``` narrow down to purchases from our top 100 customers (based on purchase count) ```
[search index=customer_data action=purchase top limit=100 user_id | table user_id]
``` show type of products that each user purchased ```
| stats count, list(product_category) by user_id
| eval product_category_distribution = ???
| table user_id, product_category_distribution&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;but I can't find any such function ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 14:26:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistical-distribution-of-multivalue-entry-in/m-p/645616#M223530</guid>
      <dc:creator>JamesWierzba</dc:creator>
      <dc:date>2023-06-05T14:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get statistical distribution of multivalue entry in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistical-distribution-of-multivalue-entry-in/m-p/645622#M223534</link>
      <description>&lt;LI-CODE lang="markup"&gt;``` get all purchases ```
index=customer_data action=purchase
``` narrow down to purchases from our top 100 customers (based on purchase count) ```
[search index=customer_data action=purchase top limit=100 user_id | table user_id]
``` show type of products that each user purchased ```
| stats count, list(product_category) as product_category by user_id
| stats values(count) as total count by user_id product_category
| eval product_category=product_category."=".round(100*count/total,2)."%"
| stats values(product_category) as product_category by user_id
| eval product_category=mvjoin(product_category,", ")&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 03 Jun 2023 05:32:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistical-distribution-of-multivalue-entry-in/m-p/645622#M223534</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-06-03T05:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Get statistical distribution of multivalue entry in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistical-distribution-of-multivalue-entry-in/m-p/645624#M223535</link>
      <description>&lt;P&gt;You count by category first, then device this count by total.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=customer_data action=purchase
| top limit=100 user_id
``` the above should give you all purchases by top 100 users ```
| stats count by user_id product_category
| eventstats sum(count) as total by user_id
| eval percent = round(100 * count / total, 2)
| stats values(eval(product_category . "=" . percent . "%")) as product_category by user_id
| eval product_category = mvjoin(product_category)&lt;/LI-CODE&gt;&lt;P&gt;Here, I fail to see why you need a subsearch to pick out top 100 when the top 100 command should suffice. &amp;nbsp;But if that is needed, just add it to the top.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 05:49:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-statistical-distribution-of-multivalue-entry-in/m-p/645624#M223535</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-06-03T05:49:06Z</dc:date>
    </item>
  </channel>
</rss>

