<?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 write an eval search to fetch the value of field2 corresponding to field1? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218270#M64143</link>
    <description>&lt;P&gt;Have you tried the search posted by me?&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jan 2016 10:58:35 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2016-01-08T10:58:35Z</dc:date>
    <item>
      <title>How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218263#M64136</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;How do I write an eval statement to fetch the value of field2 corresponding to field1?&lt;BR /&gt;
For example, consider the table below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1  field2
Orange  10
apple    12
potato  13
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If field1 value is orange, I want to assign a value of abc as corresponding field2 ..here it is 10&lt;BR /&gt;
..|eval abc= value of field2 for orange..&lt;/P&gt;

&lt;P&gt;Kindly help me in writing the search.&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;BR /&gt;
Muthu&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 07:15:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218263#M64136</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-08T07:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218264#M64137</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearch | eval field2 = if(match(field1,"Orange")), field1, field2) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If field1 matches Orange, then assign field1 to field2, else assign field2&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 07:25:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218264#M64137</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-08T07:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218265#M64138</link>
      <description>&lt;P&gt;thanks for your reply:&lt;BR /&gt;
Here im trying to create another field3&lt;BR /&gt;
as per your suggestion im getting output like&lt;BR /&gt;
field1  field2  field3&lt;BR /&gt;
Orange  10         10&lt;BR /&gt;
apple   12         12&lt;BR /&gt;
potato  13         13&lt;/P&gt;

&lt;P&gt;but i would like to have result as below:&lt;BR /&gt;
field1  field2  field3&lt;BR /&gt;
Orange  10           10&lt;BR /&gt;
apple   12           10&lt;BR /&gt;
potato  13           10&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 07:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218265#M64138</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-08T07:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218266#M64139</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; |eval abc=if(field1=="Orange",field2,"")|eventstats values(abc) as abc
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2016 07:41:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218266#M64139</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-01-08T07:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218267#M64140</link>
      <description>&lt;P&gt;try:&lt;BR /&gt;
     yoursearch| eval abc= if(match(field1,"Orange")), field2, field2)  | eval field3 = if(match(field1,"Orange")), field2, abc) &lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 08:20:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218267#M64140</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2016-01-08T08:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218268#M64141</link>
      <description>&lt;P&gt;Hi, so assuming you want to set the value of field3 in ALL your events to be field2 when field1 matches Orange, this is what I would do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputcsv mycsv.csv
| join type=left [
   | inputcsv mycsv.csv
   | search field1 = "Orange"
   | eval fieldNEW = field2
   | fields fieldNEW
]
| eval field3 = fieldNEW
| fields - fieldNEW
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;mycsv.csv is just a csv matching the content of your table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1  field2  field3
Orange  10  11
apple   12  12
potato  13  13
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the query returns the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1  field2  field3
Orange  10  10
apple   12  10
potato  13  10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2016 08:36:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218268#M64141</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-08T08:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218269#M64142</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
also here if i want to save the value of field2 corresponding to filed1 value orange say here is 10 as another variable abc..how can i do that?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 10:32:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218269#M64142</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-08T10:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218270#M64143</link>
      <description>&lt;P&gt;Have you tried the search posted by me?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 10:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218270#M64143</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-01-08T10:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218271#M64144</link>
      <description>&lt;P&gt;thx Mr renjith.nair you are right&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 11:10:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218271#M64144</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2016-01-08T11:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218272#M64145</link>
      <description>&lt;P&gt;yes it is working for me..thx&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 05:54:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218272#M64145</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-11T05:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218273#M64146</link>
      <description>&lt;P&gt;hi all,&lt;BR /&gt;
With your previous suggestion i can able to create a parameter like in field3,but i want field pass and fail should get calculated like below.&lt;/P&gt;

&lt;P&gt;Need your help!&lt;/P&gt;

&lt;P&gt;field1  field2  field3  pass    fail&lt;BR /&gt;
Orange  10             10               10  0&lt;BR /&gt;
apple   9              10                9          1&lt;BR /&gt;
potato  7              10                7         3&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 07:38:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218273#M64146</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-11T07:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218274#M64147</link>
      <description>&lt;P&gt;Pass or fail based on what and how?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 08:10:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218274#M64147</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-01-11T08:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218275#M64148</link>
      <description>&lt;P&gt;Pass = field3-field2&lt;BR /&gt;
fail = field2-field3&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 09:22:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218275#M64148</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-11T09:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218276#M64149</link>
      <description>&lt;P&gt;Did you try |eval Pass=field3-field2|eval Fail=Field2-Field2 ?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 09:39:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218276#M64149</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-01-11T09:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218277#M64150</link>
      <description>&lt;P&gt;yes i did Ranjith, but unfortunately im getting result for only one row not for all rows..Actually i'm struck here..&lt;/P&gt;

&lt;P&gt;field1 field2 field3 pass fail&lt;BR /&gt;
Orange 10 10 10 0&lt;BR /&gt;
apple     9 10 &lt;BR /&gt;
potato   7 10 &lt;/P&gt;

&lt;P&gt;How to make this calculations happen to all rows?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 09:55:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218277#M64150</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-11T09:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218278#M64151</link>
      <description>&lt;P&gt;what i'm trying to do here is:&lt;BR /&gt;
step1: i will check for field1 value..if it is orange&lt;BR /&gt;
step2: fetch the corresponding value in field2..here the value is 10&lt;BR /&gt;
step3: Assign this value to abc..such that abc=10&lt;BR /&gt;
step4: eval new field pass =field2-abc..if it is equal to zero then value =abc else&lt;BR /&gt;
step5: eval new field fail - gives the difference and provide me the difference.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 10:03:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218278#M64151</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-11T10:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218279#M64152</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search
|eval field3=if(field1=="Orange",field2,"")|eventstats values(field3) as field3
|eval field3=mvindex(field3,1)|eval status=if(field2==field3,field2,(field2-field3))
|table sourcetype field2 field3 status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   your search
    |eval field3=if(field1=="Orange",field2,"")|eventstats values(field3) as field3
    |eval field3=mvindex(field3,1)|eval status=if(field2==field3,"Pass (".field2.")","Fail (".(field2-field3).")")
    |table sourcetype field2 field3 status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search
|eval field3=if(field1=="Orange",field2,"")|eventstats values(field3) as field3
|eval field3=mvindex(field3,1)|eval pass=if(field2==field3,field2,"")|eval fail=if(field2==field3,"",(field2-field3))
|table sourcetype field2 field3 pass fail
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jan 2016 10:32:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218279#M64152</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-01-11T10:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218280#M64153</link>
      <description>&lt;P&gt;will you be able to explain me why we need to use mvindex here after assigning values(field3) as field3 ?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 10:54:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218280#M64153</guid>
      <dc:creator>muthvin</dc:creator>
      <dc:date>2016-01-11T10:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an eval search to fetch the value of field2 corresponding to field1?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218281#M64154</link>
      <description>&lt;P&gt;Because in eventstats we are taking values(field3) which is a list includes "" and value. To get the value from a multivalue field we use mvindex&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/Search/Parsemultivaluefields"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/Search/Parsemultivaluefields&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 12:03:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-an-eval-search-to-fetch-the-value-of-field2/m-p/218281#M64154</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2016-01-11T12:03:11Z</dc:date>
    </item>
  </channel>
</rss>

