<?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 values of a formula in a timechart command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316186#M175358</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am using the below query to timechart the values of offers (STATUS=ACCEPTED) from midnight, of the current day, and compare them to lastweek. I had found this query on these forums, plugged it in and it works beautifully!&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;index="offers" STATUS="ACCEPTED" earliest=-7d@d&lt;BR /&gt;&lt;BR /&gt;
| eval StartTime=relative_time(now(), "@d")&lt;BR /&gt;&lt;BR /&gt;
| eval Series=case(&lt;BR /&gt;
       _time &amp;gt;=StartTime, "today",&lt;BR /&gt;
       _time &amp;lt;= relative_time(now(), "-6d@d"), "LastWk")&lt;BR /&gt;&lt;BR /&gt;
| timechart span=5m count by Series&lt;BR /&gt;&lt;BR /&gt;
| eval Time = strftime(_time, "%H:%M")&lt;BR /&gt;&lt;BR /&gt;
| chart sum(LastWk) as LastWeek, sum(today) as Today by Time &lt;BR /&gt;
| eval Today=if(Today==0, "", Today)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;My problem is I am trying to insert the below "eval Percent..."  so I can compare "Percent" today vs lastweek, in the above "Series".&lt;BR /&gt;
&lt;STRONG&gt;count(STATUS) AS total, count(eval(STATUS="ACCEPTED")) AS Accepted&lt;BR /&gt;
eval Percent=((Accepted/total)*100)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I tried timewrap, but while that is nice, it is a super slow process and only compares a 24h "moving window" &lt;/P&gt;

&lt;P&gt;I tried doing things like:&lt;BR /&gt;
| timechart span=5m count(STATUS) AS total, count(eval(STATUS="ACCEPTED")) AS Accepted by Series&lt;BR /&gt;&lt;BR /&gt;
|eval Percent=((Accepted/total)*100)&lt;/P&gt;

&lt;P&gt;and a few other combinations but none seemed to work.&lt;BR /&gt;
Any help would be appreciated!&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 12:58:31 GMT</pubDate>
    <dc:creator>mtrochym</dc:creator>
    <dc:date>2020-09-29T12:58:31Z</dc:date>
    <item>
      <title>eval values of a formula in a timechart command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316186#M175358</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am using the below query to timechart the values of offers (STATUS=ACCEPTED) from midnight, of the current day, and compare them to lastweek. I had found this query on these forums, plugged it in and it works beautifully!&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;index="offers" STATUS="ACCEPTED" earliest=-7d@d&lt;BR /&gt;&lt;BR /&gt;
| eval StartTime=relative_time(now(), "@d")&lt;BR /&gt;&lt;BR /&gt;
| eval Series=case(&lt;BR /&gt;
       _time &amp;gt;=StartTime, "today",&lt;BR /&gt;
       _time &amp;lt;= relative_time(now(), "-6d@d"), "LastWk")&lt;BR /&gt;&lt;BR /&gt;
| timechart span=5m count by Series&lt;BR /&gt;&lt;BR /&gt;
| eval Time = strftime(_time, "%H:%M")&lt;BR /&gt;&lt;BR /&gt;
| chart sum(LastWk) as LastWeek, sum(today) as Today by Time &lt;BR /&gt;
| eval Today=if(Today==0, "", Today)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;My problem is I am trying to insert the below "eval Percent..."  so I can compare "Percent" today vs lastweek, in the above "Series".&lt;BR /&gt;
&lt;STRONG&gt;count(STATUS) AS total, count(eval(STATUS="ACCEPTED")) AS Accepted&lt;BR /&gt;
eval Percent=((Accepted/total)*100)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I tried timewrap, but while that is nice, it is a super slow process and only compares a 24h "moving window" &lt;/P&gt;

&lt;P&gt;I tried doing things like:&lt;BR /&gt;
| timechart span=5m count(STATUS) AS total, count(eval(STATUS="ACCEPTED")) AS Accepted by Series&lt;BR /&gt;&lt;BR /&gt;
|eval Percent=((Accepted/total)*100)&lt;/P&gt;

&lt;P&gt;and a few other combinations but none seemed to work.&lt;BR /&gt;
Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316186#M175358</guid>
      <dc:creator>mtrochym</dc:creator>
      <dc:date>2020-09-29T12:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: eval values of a formula in a timechart command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316187#M175359</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="offers" STATUS="*" earliest=-7d@d 
| eval StartTime=relative_time(now(), "@d") 
| eval Series=case(
_time &amp;gt;=StartTime, "today",
_time &amp;lt;= relative_time(now(), "-6d@d"), "LastWk") 
| where isnotnull(Series)
| eval _time=if(Series="LastWk",_time+(86400*7),_time)
| bucket span=5m  _time
| chart count(STATUS) AS total, count(eval(STATUS="ACCEPTED")) AS Accepted by _time Series
| eval 'Percent: Today'=(('Accepted: Today'/'total: Today')*100)
| eval 'Percent: LastWk'=(('Accepted: LastWk'/'total: LastWk')*100)
| eval Time = strftime(_time, "%H:%M") | fields -_time
| table Time Percent* *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2017 16:08:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316187#M175359</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-23T16:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: eval values of a formula in a timechart command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316188#M175360</link>
      <description>&lt;P&gt;Hmm. I think I see where you're going with this but I tried this and unfortunately it did not work. The search took about 45min to run and didn't return any results.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 00:37:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316188#M175360</guid>
      <dc:creator>mtrochym</dc:creator>
      <dc:date>2017-02-28T00:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: eval values of a formula in a timechart command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316189#M175361</link>
      <description>&lt;P&gt;yesssss great&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 01:17:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-values-of-a-formula-in-a-timechart-command/m-p/316189#M175361</guid>
      <dc:creator>jamojamil</dc:creator>
      <dc:date>2017-02-28T01:17:36Z</dc:date>
    </item>
  </channel>
</rss>

