<?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 edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200755#M58212</link>
    <description>&lt;P&gt;That did the trick. My only concern is that the query runs for a &lt;EM&gt;really&lt;/EM&gt; long time now. I am not sure whether this will be manageable in the long-run (for analysis purposes). I did try to break the initial search down as best as I can but it is just really taking a long time. Is there any way to remedy this? Thanks! &lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2016 17:37:05 GMT</pubDate>
    <dc:creator>demkic</dc:creator>
    <dc:date>2016-11-01T17:37:05Z</dc:date>
    <item>
      <title>How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200749#M58206</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;

&lt;P&gt;I have Splunk version 6.2.7 and am trying to create a report to display the top 10 products sold within the last 4 hours (in quantity and displayed per product name) and compare those results to the results of 30 days ago. &lt;/P&gt;

&lt;P&gt;Ideally, what I would like to be able to see is what are the "new" products (if any) that have been purchased within the last 4 hours that were possibly not purchased 30 days ago. I am trying to find anomalies in products sold.&lt;/P&gt;

&lt;P&gt;I am not quite sure my search is displaying any "new" products that may have been sold within the last 4 hours as it compares to 30 days ago. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=.... earliest=-30d@d | stats count(product_name) as monthproduct by productname | sort 10 - monthproduct | streamstats count as MonthRank | append [ search sourcetype=... earliest=-4h@h | stats count(product_name) as hourproduct by productname | sort 10 - hourproduct | streamstats count as HourRank ] | stats first(MonthRank) as MonthRank first(HourRank) as HourRank by product_name | eval diff=MonthRank-HourRank | sort HourRank | table product_name, HourRank, MonthRank, diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is it appropriate to use &lt;CODE&gt;append&lt;/CODE&gt; before the subsearch even?&lt;/P&gt;

&lt;P&gt;Thanks so much for any insights.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 19:00:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200749#M58206</guid>
      <dc:creator>demkic</dc:creator>
      <dc:date>2016-10-31T19:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200750#M58207</link>
      <description>&lt;P&gt;There's is a typo in your search, productname vs product_name in the last segement. Other than that, your search should return right results. Why do you believe is missing in the result?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 19:47:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200750#M58207</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-31T19:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200751#M58208</link>
      <description>&lt;P&gt;Oh yes, thank you regarding that typo. Actually, it seems as if it is returning the results that I wanted. The only part that it is not able to display on the table for me is the actual quantity of the products for "monthproduct" and "hourproduct" (...when I add in the last command: table product_name, HourRank, MonthRank, diff, monthproduct, hourproduct)&lt;/P&gt;

&lt;P&gt;I believe this is because the streamstats command and because I am turning the quantities into rankings. However, how would I be able to tweak the query to also create a column named "monthproduct" and "hourproduct" and display the number of products sold per product?&lt;/P&gt;

&lt;P&gt;Many thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 20:14:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200751#M58208</guid>
      <dc:creator>demkic</dc:creator>
      <dc:date>2016-10-31T20:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200752#M58209</link>
      <description>&lt;P&gt;Do you happen to know what can I add extra to the query to display the actual quantities of products sold in addition to what is already displayed? Unfortunately "table product_name, HourRank, MonthRank, diff, monthproduct, hourproduct" doesn't do the trick. &lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 15:56:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200752#M58209</guid>
      <dc:creator>demkic</dc:creator>
      <dc:date>2016-11-01T15:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200753#M58210</link>
      <description>&lt;P&gt;Also, thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 15:57:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200753#M58210</guid>
      <dc:creator>demkic</dc:creator>
      <dc:date>2016-11-01T15:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200754#M58211</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=.... earliest=-30d@d | stats count(product_name) as monthproduct by product_name | sort 10 - monthproduct | streamstats count as MonthRank | append [ search sourcetype=... earliest=-4h@h | stats count(product_name) as hourproduct by product_name | sort 10 - hourproduct | streamstats count as HourRank ] | stats first(MonthRank) as MonthRank first(HourRank) as HourRank values(monthproduct) as monthproduct values(hourproduct) as hourproduct by product_name | eval diff=MonthRank-HourRank | sort HourRank | table product_name, HourRank, MonthRank, diff, monthproduct , hourproduct
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 16:02:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200754#M58211</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-01T16:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200755#M58212</link>
      <description>&lt;P&gt;That did the trick. My only concern is that the query runs for a &lt;EM&gt;really&lt;/EM&gt; long time now. I am not sure whether this will be manageable in the long-run (for analysis purposes). I did try to break the initial search down as best as I can but it is just really taking a long time. Is there any way to remedy this? Thanks! &lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 17:37:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200755#M58212</guid>
      <dc:creator>demkic</dc:creator>
      <dc:date>2016-11-01T17:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to list top 10 products sold in the last 4 hours, and compare these results to 30 days ago?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200756#M58213</link>
      <description>&lt;P&gt;Well, you're querying about 31 days worth of data and it's bound to be slower. See this this work better:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=.... earliest=-30d@d | top 10 product_name showperc=f  | streamstats count as MonthRank | append [ search sourcetype=... earliest=-4h@h | top 10 product_name showperc=f | streamstats count as HourRank ] | stats first(MonthRank) as MonthRank first(HourRank) as HourRank values(monthproduct) as monthproduct values(hourproduct) as hourproduct by product_name | eval diff=MonthRank-HourRank | sort HourRank | table product_name, HourRank, MonthRank, diff, monthproduct , hourproduct
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=.... earliest=-30d@d latest=now | eval Type=if(_time&amp;gt;relative_time(now(),"-4h@h") ,"Hour", "Month") | top 10 product_name by Type showperc=f | streamstats count as rank by Type | chart values(count) as count values(rank) as rank over product_name by Type | rename "count: Hour" as hourproduct "count: Month" as monthproduct "rank: Hour" as HourRank "rank: Month" as MonthRank
| eval diff=MonthRank-HourRank | sort HourRank | table product_name, HourRank, MonthRank, diff, monthproduct , hourproduct
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 19:12:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-list-top-10-products-sold-in-the-last-4/m-p/200756#M58213</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-11-01T19:12:56Z</dc:date>
    </item>
  </channel>
</rss>

