<?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 see changes in field values when comparing today vs. yesterday? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447943#M126948</link>
    <description>&lt;P&gt;@somesoni2 I think you missed, &lt;CODE&gt;"%m/%d/%y"&lt;/CODE&gt; for &lt;CODE&gt;strftime()&lt;/CODE&gt; eval function while determining Period&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup yourlookup.csv 
| where (date == strftime(relative_time(now(), "-1d@d"), "%m/%d/%y")) OR (date == strftime(now(), "%m/%d/%y") ) 
| eval Period=if(date == strftime(relative_time(now(), "-1d@d"),"%m/%d/%y"),"Yesterday","Today") 
| chart max(battery) over device by Period 
| where Yesterday=100 AND Today&amp;lt;100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 May 2019 17:24:20 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2019-05-06T17:24:20Z</dc:date>
    <item>
      <title>How to see changes in field values when comparing today vs. yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447940#M126945</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I have a scheduled search that populates a CSV with data each day, including the current date. Here is an example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; device    battery    date
desktop     100     05/04/19
laptop      100     05/04/19
printer     100     05/04/19

desktop     100     05/05/19
laptop      100     05/05/19
printer     100     05/05/19

desktop     100     05/06/19
laptop      90      05/06/19
printer     90      05/06/19
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;What query would I need to put into an alert that would notify me when a device that had &lt;CODE&gt;100&lt;/CODE&gt; in its &lt;CODE&gt;battery&lt;/CODE&gt; field the previous day is below 100 on the current day?&lt;/STRONG&gt; The result should return just the &lt;CODE&gt;device&lt;/CODE&gt; names, which here would be &lt;CODE&gt;laptop&lt;/CODE&gt; and &lt;CODE&gt;printer&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Note: I do know this could be helpful in the query where it shows data for the current day and the previous day. Feel free to use it if you'd like: &lt;CODE&gt;| where (date == strftime(relative_time(now(), "-1d@d"), "%m/%d/%y")) OR (date == strftime(now(), "%m/%d/%y") )&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 15:20:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447940#M126945</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-05-06T15:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to see changes in field values when comparing today vs. yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447941#M126946</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;H2&gt;Updated##&lt;/H2&gt;

&lt;P&gt;Thanks @niketnilay for correcting. Updating original response with different check in eval.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup yourlookup.csv
| where (date == strftime(relative_time(now(), "-1d@d"), "%m/%d/%y")) OR (date == strftime(now(), "%m/%d/%y") )
| eval Period=if(date == strftime(date == strftime(now(), "%m/%d/%y"),"Today","Yesterday")
| chart max(battery) over device by Period
| where Yesterday=100 AND Today&amp;lt;100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Set your alert condition to raise an alert when number of events from above search is greater than 0.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 16:14:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447941#M126946</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-05-06T16:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to see changes in field values when comparing today vs. yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447942#M126947</link>
      <description>&lt;P&gt;I get this error: &lt;CODE&gt;Error in 'eval' command: The arguments to the 'strftime' function are invalid.&lt;/CODE&gt; I'm unsure why though.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 16:44:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447942#M126947</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2019-05-06T16:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to see changes in field values when comparing today vs. yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447943#M126948</link>
      <description>&lt;P&gt;@somesoni2 I think you missed, &lt;CODE&gt;"%m/%d/%y"&lt;/CODE&gt; for &lt;CODE&gt;strftime()&lt;/CODE&gt; eval function while determining Period&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup yourlookup.csv 
| where (date == strftime(relative_time(now(), "-1d@d"), "%m/%d/%y")) OR (date == strftime(now(), "%m/%d/%y") ) 
| eval Period=if(date == strftime(relative_time(now(), "-1d@d"),"%m/%d/%y"),"Yesterday","Today") 
| chart max(battery) over device by Period 
| where Yesterday=100 AND Today&amp;lt;100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 May 2019 17:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447943#M126948</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-05-06T17:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to see changes in field values when comparing today vs. yesterday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447944#M126949</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="device=desktop,battery=100,date=05/04/19 device=laptop,battery=100,date=05/04/19 device=printer,battery=100,date=05/04/19 device=desktop,battery=80,date=05/05/19 device=laptop,battery=100,date=05/05/19 device=printer,battery=100,date=05/05/19 device=desktop,battery=100,date=05/06/19 device=laptop,battery=90,date=05/06/19 device=printer,battery=90,date=05/06/19"
| makemv raw
| mvexpand raw
| rename raw AS _raw
| kv
| fields - _*

| rename COMMENT AS "Everything above generates sample data; everything below is your solution"

| eval _time = strptime(date, "%m/%d/%y")
| fields - date
| sort 0 - _time
| dedup 2 device
| reverse
| streamstats current=f last(battery) AS prev_battery BY device
| eval change = battery - prev_battery
| where isnotnull(change) AND battery&amp;lt;100 AND prev_battery=100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 May 2019 21:29:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-see-changes-in-field-values-when-comparing-today-vs/m-p/447944#M126949</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-05-11T21:29:54Z</dc:date>
    </item>
  </channel>
</rss>

