<?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: Getting full result in join/append in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499122#M139027</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2
| streamstats count
| eval _time = if (count==2,relative_time(_time,"+1d@d"), relative_time(_time,"-8d@d")) 
| makecontinuous span=5m
| where strftime(_time,"%d")==strftime(now(),"%d") OR strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d")
| eval ITEMS="a".(random() % 5 + 1)
| table _time ITEMS
`comment("this is sample data")`
| eval week=case(strftime(_time,"%d")==strftime(now(),"%d"),"COUNT_TODAY",strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d"),"COUNT_LASTWEEK")
| chart count over ITEMS by week
| eval Difference= COUNT_TODAY - COUNT_LASTWEEK
| table ITEMS COUNT_TODAY COUNT_LASTWEEK Difference
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi , how about it?&lt;BR /&gt;
When searching, please use first @woodcook 's search text.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Nov 2019 12:27:38 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2019-11-29T12:27:38Z</dc:date>
    <item>
      <title>Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499120#M139025</link>
      <description>&lt;P&gt;I have a index, where i store values of items and their count (pulled from SQL DB). I run a search to return me items of today and a sub search to return items of last week same day(-7d@d to -6d@d and @d to now).&lt;/P&gt;

&lt;P&gt;for example:&lt;BR /&gt;
Todays data&lt;BR /&gt;
ITEMS  COUNT&lt;BR /&gt;
a1      2&lt;BR /&gt;
a2      3&lt;BR /&gt;
a3      4&lt;/P&gt;

&lt;P&gt;LAST week data :&lt;BR /&gt;
ITEMS  COUNT&lt;BR /&gt;
a1      5&lt;BR /&gt;
a2     10&lt;BR /&gt;
a4     8&lt;/P&gt;

&lt;P&gt;I also want to run a calculation to calculate difference of both count.&lt;BR /&gt;
So the expected would be:&lt;/P&gt;

&lt;P&gt;ITEMS        COUNT_TODAY      COUNT_LASTWEEK              Difference&lt;BR /&gt;
a1                                 2                   5                   -3&lt;BR /&gt;
a2                       3                   10                   -7&lt;BR /&gt;
a3                       4                                      4&lt;BR /&gt;
a4                                             8                   -8&lt;/P&gt;

&lt;P&gt;I have already tried append with stats, appendcols, join, but i always miss-out some data.&lt;BR /&gt;
In append ans stats i can't do the calculation part, in appendcols lastweekdata merges with wrong set of todays data, and in join i miss out the blank part. Calculation for null values can be ignored, but if done it would be helpful.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499120#M139025</guid>
      <dc:creator>nkumar6</dc:creator>
      <dc:date>2020-09-30T03:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499121#M139026</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" AND sourcetype="AndSourcetypeToo" ((earliest=-8d@d latest=-7d@d) OR (earliest=@d latest=now))
| timechart limit=0 useother=false cont=f span=1d count BY items
| where _time = relative_time(now(), "-8d@d") OR _time = relative_time(now(), "@d")
| untable _time items count
| eval _time = if(_time == relative_time(now(), "-8d@d"), "LASTWEEK", "TODAY")
| xyseries items _time count
| eval DIFFERENCE = TODAY - LASTWEEK
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is a run-anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|tstats count WHERE index="*" AND sourcetype="*" ((earliest=-8d@d latest=-7d@d) OR (earliest=@d latest=now)) BY sourcetype _time span=1h
| timechart limit=0 useother=false cont=f span=1h count BY sourcetype
| where _time = relative_time(now(), "-8d@d") OR _time = relative_time(now(), "@d")
| untable _time sourcetype count
| eval _time = if(_time == relative_time(now(), "-8d@d"), "LASTWEEK", "TODAY")
| xyseries sourcetype _time count
| eval DIFFERENCE = TODAY - LASTWEEK
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Nov 2019 02:28:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499121#M139026</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-29T02:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499122#M139027</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2
| streamstats count
| eval _time = if (count==2,relative_time(_time,"+1d@d"), relative_time(_time,"-8d@d")) 
| makecontinuous span=5m
| where strftime(_time,"%d")==strftime(now(),"%d") OR strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d")
| eval ITEMS="a".(random() % 5 + 1)
| table _time ITEMS
`comment("this is sample data")`
| eval week=case(strftime(_time,"%d")==strftime(now(),"%d"),"COUNT_TODAY",strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d"),"COUNT_LASTWEEK")
| chart count over ITEMS by week
| eval Difference= COUNT_TODAY - COUNT_LASTWEEK
| table ITEMS COUNT_TODAY COUNT_LASTWEEK Difference
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi , how about it?&lt;BR /&gt;
When searching, please use first @woodcook 's search text.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 12:27:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499122#M139027</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-29T12:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499123#M139028</link>
      <description>&lt;P&gt;While executing your suggestion i get error as "Error in 'makeresults' command: This command must be the first command of a search".&lt;/P&gt;

&lt;P&gt;Did I miss out something?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 20:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499123#M139028</guid>
      <dc:creator>nkumar6</dc:creator>
      <dc:date>2019-11-29T20:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499124#M139029</link>
      <description>&lt;P&gt;You need the leading &lt;CODE&gt;pipe&lt;/CODE&gt; as in &lt;CODE&gt;| makeresults ...&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 21:05:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499124#M139029</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-29T21:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499125#M139030</link>
      <description>&lt;P&gt;I did like this&lt;BR /&gt;
&lt;CODE&gt;index=abc AND sourcetype=xyz ((earliest=-8d@d latest=-7d@d) OR (earliest=@d latest=now))  &lt;BR /&gt;
 | makeresults count=2&lt;BR /&gt;
 | streamstats count&lt;BR /&gt;
 | eval _time = if (count==2,relative_time(_time,"+1d@d"), relative_time(_time,"-8d@d")) &lt;BR /&gt;
 | makecontinuous span=5m&lt;BR /&gt;
 | where strftime(_time,"%d")==strftime(now(),"%d") OR strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d")&lt;BR /&gt;
 | eval ITEM="a".(random() % 5 + 1)&lt;BR /&gt;
 | table _time ITEM&lt;BR /&gt;
 | eval week=case(strftime(_time,"%d")==strftime(now(),"%d"),"COUNT_TODAY",strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d"),"COUNT_LASTWEEK")&lt;BR /&gt;
 | chart count over ITEM by week&lt;BR /&gt;
 | eval Difference= COUNT_TODAY - COUNT_LASTWEEK&lt;BR /&gt;
 | table ITEM, COUNT_TODAY, COUNT_LASTWEEK, Difference&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 21:38:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499125#M139030</guid>
      <dc:creator>nkumar6</dc:creator>
      <dc:date>2019-11-29T21:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499126#M139031</link>
      <description>&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/Makeresults"&gt;makeresults&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This command must be written at &lt;STRONG&gt;the beginning of the search.&lt;/STRONG&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;When searching, please use first @woodcook 's search text.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;It was a remark when actually applying it to your query ...&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 23:01:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499126#M139031</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-29T23:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499127#M139032</link>
      <description>&lt;P&gt;Just try my top answer but change &lt;CODE&gt;YouShouldAlwaysSpecifyAnIndex&lt;/CODE&gt; to your actual index value and &lt;CODE&gt;AndSourcetypeToo&lt;/CODE&gt; to your actual sourcettype value.  You have had working answers for days now.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 03:59:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499127#M139032</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-30T03:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499128#M139033</link>
      <description>&lt;P&gt;Hi @to4kawa  ,&lt;BR /&gt;
can you help me with this, I am still failing to do so, neither I can find any other example like this.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 11:47:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499128#M139033</guid>
      <dc:creator>nkumar6</dc:creator>
      <dc:date>2019-12-04T11:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499129#M139034</link>
      <description>&lt;P&gt;I don't get any error but nor do I get any result. and &lt;CODE&gt;eval ITEM="a".(random() % 5 + 1)&lt;/CODE&gt; wouldn't work in my case, as it was just example I used for a1,a2,a3 etc...&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 11:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499129#M139034</guid>
      <dc:creator>nkumar6</dc:creator>
      <dc:date>2019-12-04T11:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Getting full result in join/append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499130#M139035</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; | makeresults count=2
 | streamstats count
 | eval _time = if (count==2,relative_time(_time,"+1d@d"), relative_time(_time,"-8d@d")) 
 | makecontinuous span=5m
 | where strftime(_time,"%d")==strftime(now(),"%d") OR strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d")
 | eval ITEMS="a".(random() % 5 + 1)
 | table _time ITEMS
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;please  paste this query and search, check it.&lt;BR /&gt;
This query is aim to create sample data.&lt;/P&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval week=case(strftime(_time,"%d")==strftime(now(),"%d"),"COUNT_TODAY",strftime(_time,"%d")==strftime(relative_time(now(),"-7d@d"),"%d"),"COUNT_LASTWEEK")
 | chart count over ITEMS by week
 | eval Difference= COUNT_TODAY - COUNT_LASTWEEK
 | table ITEMS COUNT_TODAY COUNT_LASTWEEK Difference
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This query is the logic of calculate what you want .&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time ITEM 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If your log has two fields in this way, my logic should work as well.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 14:37:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-full-result-in-join-append/m-p/499130#M139035</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-05T14:37:26Z</dc:date>
    </item>
  </channel>
</rss>

