<?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: evaluation with condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369719#M163040</link>
    <description>&lt;P&gt;What is the data that you used for this test? Specifically: do fields y1 and y2 actually exist?&lt;/P&gt;

&lt;P&gt;It would really help if you're a bit more clear in exactly what you are trying and what you expect as the outcome.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2018 08:52:25 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2018-02-08T08:52:25Z</dc:date>
    <item>
      <title>evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369713#M163034</link>
      <description>&lt;P&gt;I have two values x and y. Both values are dynamic (keeps on changing).&lt;BR /&gt;
x indicates _time and y indicates a value that continuosly changes with time.&lt;BR /&gt;
I want the value of y at two particular instances of x.&lt;/P&gt;

&lt;P&gt;I do this,&lt;BR /&gt;
|eval mytime = round(_time)&lt;BR /&gt;
|eval mytime2 = round(_time) - 40&lt;/P&gt;

&lt;P&gt;I wish to have value of y when x's value is mytime and &lt;BR /&gt;
the value of y when x's value is mytime2 (i.e. 40 sec before current time)&lt;BR /&gt;
If condition only helps to get the value of y when x is mytime, but it won't help when x = mytime2. When x=mytime2 , it still gives the same value as mytime. But it shouldn't be the case. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:01:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369713#M163034</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T18:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369714#M163035</link>
      <description>&lt;P&gt;could you provide sample inputs and expected output to better understand&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 07:40:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369714#M163035</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T07:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369715#M163036</link>
      <description>&lt;P&gt;&lt;STRONG&gt;X |                                               Y&lt;/STRONG&gt;&lt;BR /&gt;
1518074558|               464758&lt;BR /&gt;
1518074559|               5757657&lt;BR /&gt;
1518074560|                464533&lt;BR /&gt;
1518074561|                 667231&lt;BR /&gt;
1518074562|                 77654&lt;BR /&gt;
1518074563|               00987&lt;BR /&gt;
1518074564 |               567843&lt;/P&gt;

&lt;P&gt;X indicates UNIX time.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 07:45:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369715#M163036</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-02-08T07:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369716#M163037</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|eval result= case(x=mytime,y, x=mytime2,y)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 08:07:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369716#M163037</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T08:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369717#M163038</link>
      <description>&lt;P&gt;I tried this and I get empty value(nothing) for y1 and y2.&lt;BR /&gt;
y1 is where I want to  save y's value when it matches with mytime&lt;BR /&gt;
y2 is where I want to  save y's value when it matches mytime2.&lt;BR /&gt;
This is what I tried&lt;/P&gt;

&lt;P&gt;| eval mytime = round(_time) | eval mytime2= round(_time)-40&lt;BR /&gt;
| eval x = round(_time) &lt;BR /&gt;
| eval result= case(x=mytime,y1, x=mytime2,y2)&lt;BR /&gt;
| table mytime,mytime2,y1,y2&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:01:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369717#M163038</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T18:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369718#M163039</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval mytime = round(_time) | eval mytime2= round(_time)-40
| eval x = round(_time) 
|eval y1=if(x=mytime,y), y2=if(x=mytime2,y)
|table mytime,mytime2,y1,y2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 08:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369718#M163039</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T08:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369719#M163040</link>
      <description>&lt;P&gt;What is the data that you used for this test? Specifically: do fields y1 and y2 actually exist?&lt;/P&gt;

&lt;P&gt;It would really help if you're a bit more clear in exactly what you are trying and what you expect as the outcome.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 08:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369719#M163040</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-02-08T08:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369720#M163041</link>
      <description>&lt;P&gt;Error in 'eval' command: The arguments to the 'if' function are invalid.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 08:57:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369720#M163041</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-02-08T08:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369721#M163042</link>
      <description>&lt;P&gt;does in your data &lt;CODE&gt;y&lt;/CODE&gt; field exists?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:00:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369721#M163042</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T09:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369722#M163043</link>
      <description>&lt;P&gt;ohh my mistake.. try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval mytime = round(_time) | eval mytime2= round(_time)-40
 | eval x = round(_time) 
 |eval y1=if(x=mytime,y,null()), y2=if(x=mytime2,y,null())
 |table mytime,mytime2,y1,y2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:02:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369722#M163043</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T09:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369723#M163044</link>
      <description>&lt;P&gt;y's value changes based on x. and x indicates _time in real -time.&lt;BR /&gt;
I am looking to find the value of y based on two different instance of time(x) and save it in y1 and y2 respectively. y1 and y2 don't exist.&lt;/P&gt;

&lt;P&gt;I tried this&lt;BR /&gt;
| eval mytime = round(_time) &lt;BR /&gt;
| eval mytime2= round(_time)-40&lt;BR /&gt;
| eval x = round(_time) &lt;BR /&gt;
| eval result= case(x=mytime,y1, x=mytime2,y2)&lt;BR /&gt;
| table mytime,mytime2,y1,y2&lt;/P&gt;

&lt;P&gt;this didn't give any result&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:01:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369723#M163044</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T18:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369724#M163045</link>
      <description>&lt;P&gt;This worked. But only for y1. I don't see any values for y2. y2 column comes empty.&lt;BR /&gt;
And yes, y has value in it.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:05:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369724#M163045</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-02-08T09:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369725#M163046</link>
      <description>&lt;P&gt;could you provide what query you have tried?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:08:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369725#M163046</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T09:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369726#M163047</link>
      <description>&lt;P&gt;here if x value matches with mytime  then store y's value in y1 else null.&lt;BR /&gt;
similarly if x value matches with mytime2  then store y's value in y2 else store null.&lt;BR /&gt;
this is basic understanding of this query&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:10:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369726#M163047</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T09:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369727#M163048</link>
      <description>&lt;P&gt;| eval mytime = round(_time) | eval mytime2= round(_time)-40&lt;BR /&gt;
| eval x = round(_time) &lt;BR /&gt;
| eval y1=if(x=mytime,y,null()), y2=if(x=mytime2,y,null())&lt;BR /&gt;
| table mytime,mytime2,y1,y2&lt;/P&gt;

&lt;P&gt;somehow x value (i.e. the current time) matches with mytime and gives y data, BUT x value doesn't match with mytime2(i.e. 40 sec previous data) and gives null.&lt;/P&gt;

&lt;P&gt;I tried changing 'mytime2' to -40, -60, -30 etc... But same result.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:01:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369727#M163048</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T18:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369728#M163049</link>
      <description>&lt;P&gt;one thing i noticed how it could match x=mytime2 as you already set x value nothing but mytime value ....because &lt;CODE&gt;mytime=round(_time)&lt;/CODE&gt; and x value is also &lt;CODE&gt;round(_time)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:19:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369728#M163049</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T09:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369729#M163050</link>
      <description>&lt;P&gt;As &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206320"&gt;@493669&lt;/a&gt; already mentions above: if you set x=round(_time), how will it ever match anything else then mytime (which you also set to round(_time).&lt;/P&gt;

&lt;P&gt;And eval result=case... stores the content of y1 or y2 (depending on which case is true) in the result field. So if y1 and y2 are empty, of course that gives no result.&lt;/P&gt;

&lt;P&gt;I think two things are making it hard to answer this properly:&lt;BR /&gt;
1: your explanation of exactly what data you have and what you want as a result remains vague.&lt;BR /&gt;
2: people still try to help you along with examples, but you don't fully understand some of the commands suggested, which causes you to glue examples together in ways that don't make much sense, which only adds to the confusion.&lt;/P&gt;

&lt;P&gt;So:&lt;BR /&gt;
Please be more clear in describing what data you have and what you want to achieve AND when someone presents an example, check the Splunk search reference documentation and make sure you understand what the commands do and how to use them, so you know how to apply it to your use case.&lt;/P&gt;

&lt;P&gt;Sorry for perhaps being a bit direct on this, but in the end that is the way you will take the most out of such discussions and really improve your Splunk search skills &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:59:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369729#M163050</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-29T17:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369730#M163051</link>
      <description>&lt;P&gt;I tried this&lt;BR /&gt;
| eval mytime = round(_time) | eval mytime2= round(_time)-40&lt;BR /&gt;
| eval x = round(_time), x2 = round(_time)-40&lt;BR /&gt;
| eval y1=if(x=mytime,y,null()), y2=if(x2=mytime2,y,null())&lt;BR /&gt;
| table mytime,mytime2,y1,y2&lt;/P&gt;

&lt;P&gt;This gives me y2 value , but not the correct value. It shows me the same y2 value that of y1. I think when the condition x2=mytime2 becomes true , it is giving us the "current value of y" instead of giving the "40 sec older value of  y". &lt;BR /&gt;
But I want both the current y value and 40 sec older y value .&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369730#M163051</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T18:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369731#M163052</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206320"&gt;@493669&lt;/a&gt;&lt;BR /&gt;
I think, if  "x" were some other alphanumeric value except " _time" it might have worked.&lt;BR /&gt;
When it comes to '_time' the anomaly rises. But I could be wrong. &lt;BR /&gt;
I have applied the same logic at other instances and it have worked, But when it comes to comparing _time field it shows weirdness.  &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:01:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369731#M163052</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T18:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: evaluation with condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369732#M163053</link>
      <description>&lt;P&gt;not able to understand what you exactly want to achieve? &lt;BR /&gt;
if could you provide exact sample input and expected output...&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 09:45:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/evaluation-with-condition/m-p/369732#M163053</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T09:45:03Z</dc:date>
    </item>
  </channel>
</rss>

