<?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: Adding data from multiple fields into a new field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309805#M163565</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I tried it. It is giving just the values for Morning and Night. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        Period    Priority 2    Priority 3  Priority 4
    1   Morning   177           6204            32
    2   Night     168           6272            24
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Jan 2018 17:23:29 GMT</pubDate>
    <dc:creator>shiv1593</dc:creator>
    <dc:date>2018-01-17T17:23:29Z</dc:date>
    <item>
      <title>Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309803#M163563</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Out of the many data fields, I have three fields "Created Time", "Number" and "Priority" (Image below). What I want to do is&lt;/P&gt;

&lt;P&gt;1&amp;gt; Create three new separate fields named "Morning" where I want the timings between 7:15 AM-3:45 PM, "Afternoon" Where the time is from 3:50 PM to 11 PM and "Night" where the time is from 11:03 PM to 7 AM. (Picture Below)&lt;/P&gt;

&lt;P&gt;2&amp;gt; Then count the number of tickets corresponding to those time periods and display their count under those three groups accordingly (Like in the picture below)&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4160i2EE1C0A8FE460251/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How can I do the same. &lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 17:00:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309803#M163563</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-17T17:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309804#M163564</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving fields "Created Time", "Number" and "Priority" 
| rename COMMENT as "Converting Created Time values to number of seconds past midnight"
| eval CTime=strptime('Created Time',"%H:%M:%S %p")-relative_time(now(),"@d")
| eval Period=case(CTime&amp;gt;=26100 AND CTime&amp;lt;56700,"Morning", CTime&amp;gt;=57000 AND CTime&amp;lt;82800,"Afternoon", true(),"Night")
| chart count over Period by Priority
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jan 2018 17:09:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309804#M163564</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-17T17:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309805#M163565</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I tried it. It is giving just the values for Morning and Night. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        Period    Priority 2    Priority 3  Priority 4
    1   Morning   177           6204            32
    2   Night     168           6272            24
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jan 2018 17:23:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309805#M163565</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-17T17:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309806#M163566</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving fields "Created Time", "Number" and "Priority" 
 | eval CTime=strptime('Created Time',"%H:%M:%S %p")
 | eval Period=case(CTime&amp;gt;=strptime("7:15 AM","%H:%M %p") AND CTime&amp;lt;strptime("3:45 PM","%H:%M %p"),"Morning", CTime&amp;gt;=strptime("3:50 PM","%H:%M %p")AND CTime&amp;lt;strptime("11:00 PM","%H:%M %p"),"Afternoon", true(),"Night")
 | chart count over Period by Priority
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jan 2018 17:27:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309806#M163566</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-17T17:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309807#M163567</link>
      <description>&lt;P&gt;Tried it. It is now giving values of Afternoon and Night:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    Period         Priority 2        Priority 3   Priority 4
1   Afternoon     233                7592             20
2   Night          112               4884             36
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jan 2018 10:36:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309807#M163567</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-18T10:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309808#M163568</link>
      <description>&lt;P&gt;Hi @shiv1593,&lt;BR /&gt;
Run below query... I have tested it&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your current search giving fields "Created Time", "Number" and "Priority" &amp;gt;
 | rename COMMENT as "Converting Created Time values to number of seconds past midnight"
 | eval CTime=strptime('Created Time',"%I:%M:%S %p")-relative_time(now(),"@d")
 | eval Period=case(CTime&amp;gt;=26100 AND CTime&amp;lt;56700,"Morning", CTime&amp;gt;=57000 AND CTime&amp;lt;82800,"Afternoon", true(),"Night")
 | chart count over Period by Priority
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps you..&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 11:33:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309808#M163568</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-18T11:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309809#M163569</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;That is working like a charm. Thank you&lt;/P&gt;

&lt;P&gt;Two quick questions.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;I want to understand how the query worked. Can you explain me these two codes&lt;/P&gt;

&lt;P&gt;| eval CTime=strptime('Created Time',"%I:%M:%S %p")-relative_time(now(),"@d")&lt;/P&gt;

&lt;P&gt;| eval Period=case(CTime&amp;gt;=26100 AND CTime&amp;lt;56700,"Morning", CTime&amp;gt;=57000 AND CTime&amp;lt;82800,"Afternoon", true(),"Night")&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Can you please tell me how did you calculate these values? 26100,56700,57000 and 82800&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thanks &lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 11:51:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309809#M163569</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-18T11:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309810#M163570</link>
      <description>&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;&lt;CODE&gt;strptime&lt;/CODE&gt; command is used to convert timestamp into epoch(in seconds) so here 'Created Time' is converted into seconds then &lt;CODE&gt;relative_time&lt;/CODE&gt; command here will determines the UNIX time value of the start of today, based on the value of now() i.e. it will bring today's time to today's starting time(12:00 AM) and convert into epoch&lt;BR /&gt;
So, after substraction &lt;CODE&gt;cTime&lt;/CODE&gt; will contain today's time in seconds.&lt;BR /&gt;
refer &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/DateandTimeFunctions" target="_blank"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/DateandTimeFunctions&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;26100---&amp;gt; as you mentioned Morning time should be in between 7.15 am and 3:45 PM ..so I have converted time into seconds as (7*60*60)+(15*60)=26100 similarly calculated other time into seconds..&lt;BR /&gt;
Then checked if &lt;CODE&gt;cTime&lt;/CODE&gt; is falls between which conditions and as per assign period.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Hope this helps you..Let me know in case of any query&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309810#M163570</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2020-09-29T17:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Adding data from multiple fields into a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309811#M163571</link>
      <description>&lt;P&gt;Thanks a lot! It really has helped me a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 12:39:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-data-from-multiple-fields-into-a-new-field/m-p/309811#M163571</guid>
      <dc:creator>shiv1593</dc:creator>
      <dc:date>2018-01-18T12:39:05Z</dc:date>
    </item>
  </channel>
</rss>

