<?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 to set value for earliest and latest? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206765#M60225</link>
    <description>&lt;P&gt;The issue was with a missing comma " ' " in my query&lt;/P&gt;</description>
    <pubDate>Mon, 26 Dec 2016 06:06:35 GMT</pubDate>
    <dc:creator>avaishsplunk</dc:creator>
    <dc:date>2016-12-26T06:06:35Z</dc:date>
    <item>
      <title>How to set value for earliest and latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206761#M60221</link>
      <description>&lt;P&gt;Unable to set value for earliest and latest, I am getting errors. Below is my search query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval earliest=if(strftime(now(),"%A")=="Monday","-3d@d","-1d@d") eval latest=if(strftime(now(),"%A")&amp;lt;&amp;gt;"Monday", "-3d@s","1d@s") index=XXX sourcetype=YYY |search "XXYZ"
               |spath output=OpName path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.operationName
               |             spath output=EvType path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.eventTypeCode
               |             spath output=state path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.state
               | spath output=Line_Count path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.recordCount
               |             spath output=OCpath=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute1
               |             spath output=TimeZone path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute2
               |             spath output=CCpath=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute3
               |             eval combined=mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(OpName,EvType),state),Line_Count),OC),TimeZone),CC)
               |             mvexpand combined|eval combined=split(combined,",")|             eval  OpName=mvindex(combined,0)
               |             eval  EvType=mvindex(combined,1)
               |             eval state=mvindex(combined,2)
               |                                            eval Line_Count=mvindex(combined,3)
               |             eval OC=mvindex(combined,4)
               | eval TimeZone =mvindex(combined,5)
               |             eval CC=mvindex(combined,6)
               |where OpName="Total Reservations Count"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Dec 2016 22:25:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206761#M60221</guid>
      <dc:creator>avaishsplunk</dc:creator>
      <dc:date>2016-12-25T22:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to set value for earliest and latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206762#M60222</link>
      <description>&lt;P&gt;What errors are you getting?&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2016 23:27:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206762#M60222</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-12-25T23:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to set value for earliest and latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206763#M60223</link>
      <description>&lt;P&gt;Hello Rich,&lt;/P&gt;

&lt;P&gt;Thanks for the reply,I was getting expression is malformed error after eval earliest, i got this fixed, below is my updated search query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[| gentimes start=-1 
 | eval earliest=if(lower(strftime(now(),"%A"))="monday", "-3d@d", "-1d@d") 
 | eval latest=if(lower(strftime(now(),"%A"))="monday","-3d@s", "-1d@s")
 | table earliest, latest | format "" "" "" "" "" ""]  index=yy sourcetype=zz
 | search "xx"
 | spath output=OpName path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.operationName
 | spath output=EvType path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.eventTypeCode
 | spath output=state path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.state
 | spath output=Line_Count path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.recordCount
 | spath output=Org_Code path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute1
 | spath output=TimeZone path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute2
 | spath output=ccpath=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute3
 | eval combined=mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(OpName,EvType),state),Line_Count),Org_Code),TimeZone),cc)
 | mvexpand combined|eval combined=split(combined,",")
 | eval  OpName=mvindex(combined,0)
 | eval  EvType=mvindex(combined,1)
 | eval state=mvindex(combined,2)
 | eval Line_Count=mvindex(combined,3)
 | eval Org_Code =mvindex(combined,4)
 | eval TimeZone =mvindex(combined,5)
 | eval cc=mvindex(combined,6)
 | where OpName="abc"|append
 [search earliest=@d   index=yy sourcetype=zz
 | search "xx"
 | spath output=OpName path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.operationName
 | spath output=EvType path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.eventTypeCode
 | spath output=state path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.state
 | spath output=Line_Count path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.recordCount
 | spath output=Org_Code path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute1
 | spath output=TimeZone path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute2
 | spath output=CDC_RDC path=payload.gpmGenerateEventLogs.gpmGenerateEventLog{}.attribute3
 | eval combined=mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(OpName,EvType),state),Line_Count),Org_Code),TimeZone),CDC_RDC)
 | mvexpand combined
 | eval combined=split(combined,",")
 | eval  OpName=mvindex(combined,0)
 | eval  EvType=mvindex(combined,1)
 | eval state=mvindex(combined,2)
 | eval Line_Count=mvindex(combined,3)
 | eval Org_Code =mvindex(combined,4)
 | eval TimeZone =mvindex(combined,5)
 | eval cc=mvindex(combined,6)
 | where OpName="abc"]
 | bucket _time span=1d
 | stats sum(Line_Count) AS Requests by _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Dec 2016 23:41:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206763#M60223</guid>
      <dc:creator>avaishsplunk</dc:creator>
      <dc:date>2016-12-25T23:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to set value for earliest and latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206764#M60224</link>
      <description>&lt;P&gt;I got the issue fixed, thanks for looking into this Rich!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 06:05:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206764#M60224</guid>
      <dc:creator>avaishsplunk</dc:creator>
      <dc:date>2016-12-26T06:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to set value for earliest and latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206765#M60225</link>
      <description>&lt;P&gt;The issue was with a missing comma " ' " in my query&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 06:06:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206765#M60225</guid>
      <dc:creator>avaishsplunk</dc:creator>
      <dc:date>2016-12-26T06:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to set value for earliest and latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206766#M60226</link>
      <description>&lt;P&gt;Kindly update your question with your query which needs assistance...&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;You eval expressions are &lt;STRONG&gt;missing comma&lt;/STRONG&gt; before default case 1==1 expression. &lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Also please choose appropriate default value since &lt;STRONG&gt;Others is not valid option&lt;/STRONG&gt; for earliest or latest. Please find the snippet below:&lt;/P&gt;

&lt;P&gt;[| gentimes start=-1 &lt;BR /&gt;
 | eval earliest=case($SearchOption$ == "Last_Working_Day" AND lower(strftime(now(),"%A"))="monday", "-3d@d",&lt;BR /&gt;
     $SearchOption$ == "Last_Week_Same_Day_Time","-7d@d",&lt;BR /&gt;
     $SearchOption$ == "Last_Working_Day","-1d@d") &lt;BR /&gt;
 | eval latest=case($SearchOption$ == "Last_Working_Day" AND lower(strftime(now(),"%A"))="monday","-3d@s",&lt;BR /&gt;
     $SearchOption$=="Last_Week_Same_Day_Time","-7d@s",&lt;BR /&gt;
     $SearchOption$=="Last_Working_Day","-1d@s") &lt;BR /&gt;
 | table earliest, latest &lt;BR /&gt;
 | format "" "" "" "" "" ""]&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:12:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206766#M60226</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T12:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to set value for earliest and latest?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206767#M60227</link>
      <description>&lt;P&gt;Kindly accept if this answer has helped you fix the issue.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 12:48:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-value-for-earliest-and-latest/m-p/206767#M60227</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-12-26T12:48:14Z</dc:date>
    </item>
  </channel>
</rss>

