<?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 do I merge data with the same values in a table entry? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247967#M73975</link>
    <description>&lt;P&gt;wow - astericks dont show up here ---  stats values(asterick) as asterick by Time&lt;/P&gt;</description>
    <pubDate>Sun, 10 Jul 2016 16:47:09 GMT</pubDate>
    <dc:creator>voninski</dc:creator>
    <dc:date>2016-07-10T16:47:09Z</dc:date>
    <item>
      <title>How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247961#M73969</link>
      <description>&lt;P&gt;See the attached picture:&lt;/P&gt;

&lt;P&gt;I am looking at a count of data for deliveries from 2 months ago and the previous months.  By themselves the queries work perfectly.  I am trying to build a barchart where i can show the data together.  And am currently using the 'append' command.  I have tried appendpipe and appendcols and neither is giving me the right data.  This is as close as I have gotten.  Unfortunately though i can have multiple 'Times' that are the same for example in the picture you can see that i have entries for both the previous month and 2 months ago for 11:00AM and 11:15AM etc.  I would like to have only 1 entry for 11:00AM 11:15AM etc and then have the appropriate count for the '2 months ago' and 'previous month'&lt;/P&gt;

&lt;P&gt;The query I am currently using is :&lt;BR /&gt;
index=security      "Mailbox to On" earliest=-2mon@mon latest=-1mon@mon  | eval date=strftime(_time,"%x") |  sort  _time | dedup date | bin span=15min _time AS rounded_time |  eval rounded_time_hour_min=strftime(rounded_time,"%H:%M") | stats count BY rounded_time_hour_min | rename count AS "2 Months Ago" |append [search index=security      "Mailbox to On" earliest=-1mon@mon latest=@mon | eval date=strftime(_time,"%x") |  sort  _time | dedup date | bin span=15min _time AS rounded_time |  eval rounded_time_hour_min=strftime(rounded_time,"%H:%M") | stats count BY rounded_time_hour_min | rename count AS "Previous Month"]  | rename rounded_time_hour_min AS Time |  sort Time | fields Time  "2 Months Ago" "Previous Month"&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/146240-splunkmailsearch.jpg" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:09:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247961#M73969</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2020-09-29T10:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247962#M73970</link>
      <description>&lt;P&gt;I think I just figured this out.  I dropped the fields portion and added the following&lt;/P&gt;

&lt;P&gt;table Time, "Previous Month" "2 Months Ago" | stats values(*) as * by Time&lt;/P&gt;

&lt;P&gt;If anyone has a better idea let me know.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jul 2016 23:10:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247962#M73970</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2016-07-09T23:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247963#M73971</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=security "Mailbox to On" earliest=-2mon@mon latest=@mon | eval when=if(_time&amp;gt;relative_time(now(), "-1mon@mon"), "Previous Month", "2 Months Ago") | timechart span=15m count by when
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Jul 2016 00:00:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247963#M73971</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-10T00:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247964#M73972</link>
      <description>&lt;P&gt;You need the &lt;CODE&gt;timewrap&lt;/CODE&gt; command/app:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/1645/"&gt;https://splunkbase.splunk.com/app/1645/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2016 13:12:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247964#M73972</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-10T13:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247965#M73973</link>
      <description>&lt;P&gt;TY this looks awesome and i am planning on testing it out.  I always forget to check Splunkbase.  Always amazed at the functionality out there.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2016 16:34:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247965#M73973</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2016-07-10T16:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247966#M73974</link>
      <description>&lt;P&gt;Thank you.  This is a cleaner search.  But all I care to know is within the timeframe what is the hour&amp;amp;min that was the delivery time and divide them out.  I think I can rebuild this with your query to parse out the months.  But will still need the basic structure to a) divide things out into the 15 min buckets b) discard everything but the first time the mailbox is opened (the initial delivery) and the stats values(*) as * by Time command which merges all my results together by Time..  &lt;/P&gt;

&lt;P&gt;My final query is :&lt;/P&gt;

&lt;P&gt;index=security      "Mailbox to On" earliest=-2mon@mon latest=-1mon@mon  | eval date=strftime(_time,"%x") |  sort  _time | dedup date | bin span=15min _time AS rounded_time |  eval rounded_time_hour_min=strftime(rounded_time,"%H:%M") | stats count BY rounded_time_hour_min | rename count AS "2 Months Ago" |append [search index=security      "Mailbox to On" earliest=-1mon@mon latest=@mon | eval date=strftime(_time,"%x") |  sort  _time | dedup date | bin span=15min _time AS rounded_time |  eval rounded_time_hour_min=strftime(rounded_time,"%H:%M") | stats count BY rounded_time_hour_min | rename count AS "Previous Month"]  | append [search index=security   earliest=@mon latest=now   "Mailbox to On" | eval date=strftime(_time,"%x") |  sort  _time | dedup date | bin span=15min _time AS rounded_time |  eval rounded_time_hour_min=strftime(rounded_time,"%H:%M") | stats count BY rounded_time_hour_min | rename count AS "Current Month"] | append [search index=security   earliest=-3mon@mon latest=-2mon@mon  "Mailbox to On" | eval date=strftime(_time,"%x") |  sort  _time | dedup date | bin span=15min _time AS rounded_time |  eval rounded_time_hour_min=strftime(rounded_time,"%H:%M") | stats count BY rounded_time_hour_min | rename count AS "3 Months Ago"]| rename rounded_time_hour_min AS Time |  sort Time |table Time, "Current Month" "Previous Month" "2 Months Ago" "3 Months Ago" | stats values(*) as * by Time | fields Time, "Current Month" "Previous Month" "2 Months Ago" "3 Months Ago"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:09:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247966#M73974</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2020-09-29T10:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247967#M73975</link>
      <description>&lt;P&gt;wow - astericks dont show up here ---  stats values(asterick) as asterick by Time&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2016 16:47:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247967#M73975</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2016-07-10T16:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247968#M73976</link>
      <description>&lt;P&gt;That should do it as well, since you are using sub searches, you need to aware of the limitations. You can also achieve the 4 slices by using a case statement, instead of if. Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval when=case(_time&amp;gt;relative_time(now(), "-1mon@mon"), "Previous Month", _time&amp;lt;relative_time(now(), "-2mon@mon") AND _time&amp;gt;relative_time(now(), "-1mon@mon"), "2 Months Ago", _time&amp;lt;relative_time(now(), "-3mon@mon") AND _time&amp;gt;relative_time(now(), "-2mon@mon"), "3 Months Ago", )  | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Jul 2016 23:08:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247968#M73976</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-10T23:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247969#M73977</link>
      <description>&lt;P&gt;Indent your code 4 spaces and lead the code with a blank line.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 00:48:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247969#M73977</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-11T00:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I merge data with the same values in a table entry?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247970#M73978</link>
      <description>&lt;P&gt;This is an outstanding idea that is more efficient and helps me to avoid the subsearch limitations.  I haven't implemented it yet.  But this is definitely a much better way to go.  Thank you very much for all of your help.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 15:34:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-merge-data-with-the-same-values-in-a-table-entry/m-p/247970#M73978</guid>
      <dc:creator>rvoninski_splun</dc:creator>
      <dc:date>2016-07-11T15:34:14Z</dc:date>
    </item>
  </channel>
</rss>

