<?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: Compare products sold today vs last week same day in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629849#M218823</link>
    <description>&lt;P&gt;Modified as&amp;nbsp; "(earliest=-0@d latest=now)" and able to get the solution. Thankyou.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2023 07:59:24 GMT</pubDate>
    <dc:creator>Prathyusha891</dc:creator>
    <dc:date>2023-02-07T07:59:24Z</dc:date>
    <item>
      <title>How to compare products sold today vs last week same day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629824#M218808</link>
      <description>&lt;P&gt;Today : index=sold Product=Acer , Product=iphone&amp;nbsp;&lt;BR /&gt;last week : index=sold &amp;nbsp;Product=Samsung , Product=iphone&lt;BR /&gt;&lt;BR /&gt;Query Used :&lt;BR /&gt;index=sold earliest=-0d@d latest=now&lt;BR /&gt;|stats count as Today by Product&lt;BR /&gt;| appendcols [search index=sold earliest=-7d@d latest=-6d@d |stats count as Lastweeksameday by Product]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;As Samsung Product is not sold on "Today" that particular Product is not showing up in the Output though it was sold on "Last week". Ideally it should show as 0 for "Today" and as 1 for "Last week" in the output. Could someone please help.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 16:10:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629824#M218808</guid>
      <dc:creator>Prathyusha891</dc:creator>
      <dc:date>2023-02-09T16:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Compare products sold today vs last week same day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629829#M218811</link>
      <description>&lt;P&gt;Avoid appendcols - it is rarely the solution to any problem.&lt;/P&gt;&lt;P&gt;A number of ways to do this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sold (earliest=-d@d latest=now) OR (earliest=-7d@d latest=-6d@d)
| bin _time span=1w
| stats count by _time Product&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sold (earliest=-d@d latest=now) OR (earliest=-7d@d latest=-6d@d)
| timechart span=1w count by Product&lt;/LI-CODE&gt;&lt;P&gt;These will give you two forms of output. Depending on how you want to visualise, you can manipulate the data. For example if you do the timechart variant, you can do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Day=strftime(_time, "%F")
| fields - _time
| transpose 0 header_field=Day&lt;/LI-CODE&gt;&lt;P&gt;To turn it into a Product/Date/Date format&lt;/P&gt;&lt;P&gt;You can also turn dates into "Today" and "Last week", but that will assume that Today is always "today".&lt;/P&gt;&lt;P&gt;Or you can do it this way&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sold (earliest=-d@d latest=now) OR (earliest=-7d@d latest=-6d@d)
| eval Today=if(_time&amp;gt;=relative_time(now(), "@d"), 1, null())
| stats count(eval(if(isnull(Today), 1, null()))) as LastWeek count(eval(if(isnotnull(Today), 1, null()))) as Today by Product&lt;/LI-CODE&gt;&lt;P&gt;which sets a flag depending on whether the event time is today or not and then performs different counts according to that flag.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 06:13:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629829#M218811</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-07T06:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Compare products sold today vs last week same day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629831#M218812</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; Thanks for the help.&lt;BR /&gt;But I see count is not matching for the last week same day using the below query though its totally working fine for today's count. Could you please help.&lt;/P&gt;&lt;PRE&gt;index=sold (earliest=-d@d latest=now) OR (earliest=-7d@d latest=-6d@d)
| eval Today=if(_time&amp;gt;=relative_time(now(), "@d"), 1, null())
| stats count(eval(if(isnull(Today), 1, null()))) as LastWeek count(eval(if(isnotnull(Today), 1, null()))) as Today by Product&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 06:40:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629831#M218812</guid>
      <dc:creator>Prathyusha891</dc:creator>
      <dc:date>2023-02-07T06:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Compare products sold today vs last week same day</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629849#M218823</link>
      <description>&lt;P&gt;Modified as&amp;nbsp; "(earliest=-0@d latest=now)" and able to get the solution. Thankyou.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 07:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-products-sold-today-vs-last-week-same-day/m-p/629849#M218823</guid>
      <dc:creator>Prathyusha891</dc:creator>
      <dc:date>2023-02-07T07:59:24Z</dc:date>
    </item>
  </channel>
</rss>

