<?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 How to create a new Quarter field with specific conditions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-Quarter-field-with-specific-conditions/m-p/641565#M222250</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I need to set a condition in Splunk for how the business quarters are set up in my place of work. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In my job, the new financial year starts each year on February 1st. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The 1st quarter is between February to April inclusive, the 2nd quarter is May to July inclusive, the 3rd quarter is August to October inclusive, and the 4th quarter is November to January inclusive.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Currently I have this Splunk query:&lt;BR /&gt;index=_internal earliest=-1y latest=now&lt;BR /&gt;| eval month=strftime(_time, "%m")&lt;BR /&gt;| eval quarter = case(&lt;BR /&gt;month&amp;gt;=2 AND month&amp;lt;=4, "Q1",&lt;BR /&gt;month&amp;gt;=5 AND month&amp;lt;=7, "Q2",&lt;BR /&gt;month&amp;gt;=8 AND month&amp;lt;=10, "Q3",&lt;BR /&gt;month&amp;gt;=11 OR month&amp;lt;=1, "Q4"&lt;BR /&gt;)&lt;BR /&gt;| eval year = if(month&amp;gt;=2, strftime("%y", relative_time(now(), "@y")+1."y"), strftime("%y", now()))&lt;BR /&gt;| eval quarter = "FY" . year . quarter&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, I am receiving the following error:&lt;BR /&gt;Error in 'eval' command: The expression is malformed. Expected ).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How can I set a new field called "Quarter" with this information&amp;nbsp; this in a Splunk command or query?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Many thanks as always!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Apr 2023 13:48:09 GMT</pubDate>
    <dc:creator>POR160893</dc:creator>
    <dc:date>2023-04-27T13:48:09Z</dc:date>
    <item>
      <title>How to create a new Quarter field with specific conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-Quarter-field-with-specific-conditions/m-p/641565#M222250</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I need to set a condition in Splunk for how the business quarters are set up in my place of work. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In my job, the new financial year starts each year on February 1st. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The 1st quarter is between February to April inclusive, the 2nd quarter is May to July inclusive, the 3rd quarter is August to October inclusive, and the 4th quarter is November to January inclusive.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Currently I have this Splunk query:&lt;BR /&gt;index=_internal earliest=-1y latest=now&lt;BR /&gt;| eval month=strftime(_time, "%m")&lt;BR /&gt;| eval quarter = case(&lt;BR /&gt;month&amp;gt;=2 AND month&amp;lt;=4, "Q1",&lt;BR /&gt;month&amp;gt;=5 AND month&amp;lt;=7, "Q2",&lt;BR /&gt;month&amp;gt;=8 AND month&amp;lt;=10, "Q3",&lt;BR /&gt;month&amp;gt;=11 OR month&amp;lt;=1, "Q4"&lt;BR /&gt;)&lt;BR /&gt;| eval year = if(month&amp;gt;=2, strftime("%y", relative_time(now(), "@y")+1."y"), strftime("%y", now()))&lt;BR /&gt;| eval quarter = "FY" . year . quarter&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, I am receiving the following error:&lt;BR /&gt;Error in 'eval' command: The expression is malformed. Expected ).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How can I set a new field called "Quarter" with this information&amp;nbsp; this in a Splunk command or query?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Many thanks as always!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 13:48:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-Quarter-field-with-specific-conditions/m-p/641565#M222250</guid>
      <dc:creator>POR160893</dc:creator>
      <dc:date>2023-04-27T13:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new Quarter field with specific conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-Quarter-field-with-specific-conditions/m-p/641579#M222252</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/240743"&gt;@POR160893&lt;/a&gt;I think you were almost there.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval year = if(month&amp;gt;=2, strftime(relative_time(now(), "@y+1y"), "%y"), strftime(now(), "%y"))
| eval quarter = "FY" . year . quarter&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Changes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Combined the "@y+1y" into a single string (that was the error)&lt;/LI&gt;&lt;LI&gt;Switched arguments in strftime (first the date, then the format)&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 27 Apr 2023 12:22:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-Quarter-field-with-specific-conditions/m-p/641579#M222252</guid>
      <dc:creator>rut</dc:creator>
      <dc:date>2023-04-27T12:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new Quarter field with specific conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-Quarter-field-with-specific-conditions/m-p/641581#M222253</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/240743"&gt;@POR160893&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;there's an error in the strftime definition: you must use field, format not format,field.&lt;/P&gt;&lt;P&gt;In other words, please, try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval year = if(month&amp;gt;=2, strftime(relative_time(now(), "@y")+1,"%y"), strftime(now(),"%y"))&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 12:23:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-Quarter-field-with-specific-conditions/m-p/641581#M222253</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-04-27T12:23:41Z</dc:date>
    </item>
  </channel>
</rss>

