<?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 create search stirng for the given qestions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-search-stirng-for-the-given-qestions/m-p/583781#M203295</link>
    <description>&lt;P&gt;I need the results for this question: What if you wanted to find the top product sold and how many people bought it?&lt;/P&gt;&lt;P&gt;Actually, I found this question on given link. &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchTutorial/Useasubsearch" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchTutorial/Useasubsearch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I'm new to Splunk, and I tried various strings but not able to find the perfect string.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="faaku_0-1644011753554.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17832iBF369A87B032ACE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="faaku_0-1644011753554.png" alt="faaku_0-1644011753554.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Feb 2022 21:57:01 GMT</pubDate>
    <dc:creator>faaku</dc:creator>
    <dc:date>2022-02-04T21:57:01Z</dc:date>
    <item>
      <title>How to create search stirng for the given qestions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-search-stirng-for-the-given-qestions/m-p/583781#M203295</link>
      <description>&lt;P&gt;I need the results for this question: What if you wanted to find the top product sold and how many people bought it?&lt;/P&gt;&lt;P&gt;Actually, I found this question on given link. &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchTutorial/Useasubsearch" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.4/SearchTutorial/Useasubsearch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I'm new to Splunk, and I tried various strings but not able to find the perfect string.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="faaku_0-1644011753554.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17832iBF369A87B032ACE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="faaku_0-1644011753554.png" alt="faaku_0-1644011753554.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 21:57:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-search-stirng-for-the-given-qestions/m-p/583781#M203295</guid>
      <dc:creator>faaku</dc:creator>
      <dc:date>2022-02-04T21:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create search stirng for the given qestions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-search-stirng-for-the-given-qestions/m-p/583787#M203298</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;try something like this:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="markup"&gt;| stats count AS "Total Purchased", distinct_count(clientip) AS "Customers" by productId&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Replace the last stats from the docs page with the above one and it should show you what you have asked for &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 22:44:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-search-stirng-for-the-given-qestions/m-p/583787#M203298</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2022-02-04T22:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to create search stirng for the given qestions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-search-stirng-for-the-given-qestions/m-p/583794#M203302</link>
      <description>&lt;P&gt;In general, due to the reasons outlined in a frame on the webpage you pointed to, it's actually a good practice to avoid subsearches if it's possible and use other means of finding your result.&lt;/P&gt;&lt;P&gt;Anyway, using a subsearch you'd want to find a top product&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;search sourcetype=access_* status=200 action=purchase 
    | top limit=1 product
    | table product&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This search put into a subsearch would effectively yield a "product=something" condition in runtime.&lt;/P&gt;&lt;P&gt;So you'd need to use it to select the purchases of this particular product and count the customers&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;search sourcetype=access_* status=200 action=purchase&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ search sourcetype=access_* status=200 action=purchase 
    | top limit=1 product
    | table product&amp;nbsp;]&lt;BR /&gt;|&amp;nbsp;stats&amp;nbsp;dc(clientip)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Assuming that you distinguish clients by clientip.&lt;/P&gt;&lt;P&gt;You can however get the same result another way (and in this case it's relatively easy; sometimes it's more complicated)&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;search sourcetype=access_* status=200 action=purchase&lt;BR /&gt;|&amp;nbsp;stats&amp;nbsp;dc(clientip)&amp;nbsp;count&amp;nbsp;by&amp;nbsp;product&lt;BR /&gt;|&amp;nbsp;sort&amp;nbsp;-&amp;nbsp;count&lt;BR /&gt;|&amp;nbsp;head&amp;nbsp;1&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 23:20:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-search-stirng-for-the-given-qestions/m-p/583794#M203302</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-02-04T23:20:35Z</dc:date>
    </item>
  </channel>
</rss>

