<?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 Eval Case Sequence on Conditions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545672#M154618</link>
    <description>&lt;P&gt;Hi Splunk Community,&lt;/P&gt;&lt;P&gt;How does Spunk prioritize conditional case functions? Lets say I have a case function with 2 conditions - they work fine, and results are as expected, but then lets say I flip the conditions. What I see happen when I flip the conditions in the case function the results are not correct. Shouldn't Splunk be able to still check which condition it applies to even though I have flipped the conditions?&amp;nbsp; Example below:&lt;BR /&gt;&lt;BR /&gt;Case: TimeSchedule should output the closest 7th min or 37th min - so every half hour past the 7th min or 37th min from the zipTime_epoch.&lt;/P&gt;&lt;P&gt;Works Fine as output TimeSchedule should be &lt;SPAN&gt;2021-03-06 23:37:59.000000&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval zipTime="2021-03-06 23:35:59.000"
| eval zipTime_epoch=strptime(zipTime, "%Y-%m-%d %H:%M:%S.%6N")
| eval lastunzip_hour=tonumber(strftime(zipTime_epoch, "%H"))
| eval lastunzip_min=tonumber(strftime(zipTime_epoch, "%M"))
| eval lastunzip_sec=round(zipTime_epoch%60,6)
| eval TimeSchedule=strftime(case(lastunzip_min%30 &amp;lt; 7, zipTime_epoch-zipTime_epoch%1800+420+lastunzip_sec,lastunzip_min!=37 AND lastunzip_min!=7, zipTime_epoch-zipTime_epoch%1800+2220+lastunzip_sec,1=1,zipTime_epoch),"%Y-%m-%d %H:%M:%S.%6N")

| table TimeSchedule, zipTime, lastunzip_hour, lastunzip_min, lastunzip_sec, zipTime_epoch&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does not work fine when case in conditions are flipped- output should be &lt;SPAN&gt;2021-03-06 23:37:59.000000&lt;/SPAN&gt; instead.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval zipTime="2021-03-06 23:35:59.000"
| eval zipTime_epoch=strptime(zipTime, "%Y-%m-%d %H:%M:%S.%6N")
| eval lastunzip_hour=tonumber(strftime(zipTime_epoch, "%H"))
| eval lastunzip_min=tonumber(strftime(zipTime_epoch, "%M"))
| eval lastunzip_sec=round(zipTime_epoch%60,6)
| eval TimeSchedule=strftime(case( lastunzip_min!=37 AND lastunzip_min!=7, zipTime_epoch-zipTime_epoch%1800+2220+lastunzip_sec,lastunzip_min%30 &amp;lt; 7, zipTime_epoch_epoch-zipTime_epoch_epoch%1800+420+lastunzip_sec,1=1,zipTime_epoch),"%Y-%m-%d %H:%M:%S.%6N")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 27 Mar 2021 00:43:05 GMT</pubDate>
    <dc:creator>Mary666</dc:creator>
    <dc:date>2021-03-27T00:43:05Z</dc:date>
    <item>
      <title>Eval Case Sequence on Conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545672#M154618</link>
      <description>&lt;P&gt;Hi Splunk Community,&lt;/P&gt;&lt;P&gt;How does Spunk prioritize conditional case functions? Lets say I have a case function with 2 conditions - they work fine, and results are as expected, but then lets say I flip the conditions. What I see happen when I flip the conditions in the case function the results are not correct. Shouldn't Splunk be able to still check which condition it applies to even though I have flipped the conditions?&amp;nbsp; Example below:&lt;BR /&gt;&lt;BR /&gt;Case: TimeSchedule should output the closest 7th min or 37th min - so every half hour past the 7th min or 37th min from the zipTime_epoch.&lt;/P&gt;&lt;P&gt;Works Fine as output TimeSchedule should be &lt;SPAN&gt;2021-03-06 23:37:59.000000&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval zipTime="2021-03-06 23:35:59.000"
| eval zipTime_epoch=strptime(zipTime, "%Y-%m-%d %H:%M:%S.%6N")
| eval lastunzip_hour=tonumber(strftime(zipTime_epoch, "%H"))
| eval lastunzip_min=tonumber(strftime(zipTime_epoch, "%M"))
| eval lastunzip_sec=round(zipTime_epoch%60,6)
| eval TimeSchedule=strftime(case(lastunzip_min%30 &amp;lt; 7, zipTime_epoch-zipTime_epoch%1800+420+lastunzip_sec,lastunzip_min!=37 AND lastunzip_min!=7, zipTime_epoch-zipTime_epoch%1800+2220+lastunzip_sec,1=1,zipTime_epoch),"%Y-%m-%d %H:%M:%S.%6N")

| table TimeSchedule, zipTime, lastunzip_hour, lastunzip_min, lastunzip_sec, zipTime_epoch&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does not work fine when case in conditions are flipped- output should be &lt;SPAN&gt;2021-03-06 23:37:59.000000&lt;/SPAN&gt; instead.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval zipTime="2021-03-06 23:35:59.000"
| eval zipTime_epoch=strptime(zipTime, "%Y-%m-%d %H:%M:%S.%6N")
| eval lastunzip_hour=tonumber(strftime(zipTime_epoch, "%H"))
| eval lastunzip_min=tonumber(strftime(zipTime_epoch, "%M"))
| eval lastunzip_sec=round(zipTime_epoch%60,6)
| eval TimeSchedule=strftime(case( lastunzip_min!=37 AND lastunzip_min!=7, zipTime_epoch-zipTime_epoch%1800+2220+lastunzip_sec,lastunzip_min%30 &amp;lt; 7, zipTime_epoch_epoch-zipTime_epoch_epoch%1800+420+lastunzip_sec,1=1,zipTime_epoch),"%Y-%m-%d %H:%M:%S.%6N")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 00:43:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545672#M154618</guid>
      <dc:creator>Mary666</dc:creator>
      <dc:date>2021-03-27T00:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Case Sequence on Conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545677#M154620</link>
      <description>&lt;P&gt;H&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/226742"&gt;@Mary666&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Case statement checks the conditions in given sequence and exits on the first match. That is why order depends on your conditions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your second sample case, lastunzip_min values less than 7 will not hit to second case since they are not equal to 7, so they will end up by adding 2220 seconds.&lt;/P&gt;&lt;P&gt;On below sample order is not important;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval result=case(a=1,3,b=2,7)

| eval result=case(b=2,7,a=1,3)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 27 Mar 2021 05:40:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545677#M154620</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-03-27T05:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Case Sequence on Conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545736#M154659</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if I’m tracking correctly, case will take the first match as the answer?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;On my question the query’s - the min of the time stamp is 35, and both conditions are true, since min is not 37 and not 7 on first case, and on the second the modulus operator is working like so 35%30 = 5 which makes it &amp;lt;7 - which makes it also true...&lt;/P&gt;&lt;P&gt;so since both are true it will grab the first match...&lt;/P&gt;&lt;P&gt;adding 2220 in seconds instead of 427 in seconds....&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 05:00:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545736#M154659</guid>
      <dc:creator>Mary666</dc:creator>
      <dc:date>2021-03-28T05:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Eval Case Sequence on Conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545773#M154675</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/226742"&gt;@Mary666&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Yes,correct. Case stops on the very first match.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 20:30:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-Case-Sequence-on-Conditions/m-p/545773#M154675</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-03-28T20:30:53Z</dc:date>
    </item>
  </channel>
</rss>

