<?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: Eval replace function not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258458#M176413</link>
    <description>&lt;P&gt;index="myindex"| stats values(Category) |eval Category = replace(Category,"Change Request","CR") &lt;BR /&gt;
replace should not be used like this with eval, i think. i remember this one should be "Case"&lt;BR /&gt;
please try - &lt;BR /&gt;
&lt;PRE&gt;index="myindex"| stats values(Category) |eval Category = case(Category,"Change Request","CR") &lt;/PRE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2016 13:07:42 GMT</pubDate>
    <dc:creator>inventsekar</dc:creator>
    <dc:date>2016-10-18T13:07:42Z</dc:date>
    <item>
      <title>Eval replace function not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258457#M176412</link>
      <description>&lt;P&gt;I was  trying to create calculated fields as field values are huge. For 1 field I could do that. For other field where values are lengthy i could not do with eval replace&lt;BR /&gt;
EVAL-Category = replace('Category',"Change Request","CR")&lt;BR /&gt;
EVAL-Category = replace('Category',"Central Functions","CF")&lt;BR /&gt;
EVAL-Category = replace('Category',"Materials Management (MM)","MM")&lt;/P&gt;

&lt;P&gt;Also tried with query - index="myindex"| stats values(Category) |eval Category = replace(Category,"Change Request","CR") is not working&lt;BR /&gt;
Values are like Change Request-Structural Method-blah blah.. I want to replace with short form for values.. How to get that? Please suggest&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 07:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258457#M176412</guid>
      <dc:creator>k_harini</dc:creator>
      <dc:date>2016-10-18T07:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Eval replace function not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258458#M176413</link>
      <description>&lt;P&gt;index="myindex"| stats values(Category) |eval Category = replace(Category,"Change Request","CR") &lt;BR /&gt;
replace should not be used like this with eval, i think. i remember this one should be "Case"&lt;BR /&gt;
please try - &lt;BR /&gt;
&lt;PRE&gt;index="myindex"| stats values(Category) |eval Category = case(Category,"Change Request","CR") &lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 13:07:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258458#M176413</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2016-10-18T13:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Eval replace function not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258459#M176414</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; query - index="myindex"| stats values(Category) | replace "Change Request" WITH "CR" IN Category 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;All in one go:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query - index="myindex" 
| stats values(Category) 
| replace "Change Request" WITH "CR" 
  , "Central Functions" WITH "CF"
  , "Materials Management (MM)" WITH "MM" IN Category
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Oct 2016 13:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258459#M176414</guid>
      <dc:creator>lakromani</dc:creator>
      <dc:date>2016-10-18T13:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Eval replace function not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258460#M176415</link>
      <description>&lt;P&gt;I used "Eval Case" to replace the values similar to this. We ended up using a lookup table, since there were 70 possible values and the query was thus very long.&lt;/P&gt;

&lt;P&gt;Here's a snippet of my code that you could adapt. In my case, I wanted to add the more verbose value. So PEGA0001 was replaced with the longer version after the comma. The 1=1, "Google It.." at the end is a catch all, for any value not defined in the case string. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval PegaAlertV=case(PegaAlert="PEGA0001","PEGA0001-HTTP interaction time exceeds limit", 
 PegaAlert="PEGA0002","PEGA0002-Commit operation time exceeds limit", 
 PegaAlert="PEGA0003","PEGA0003-Rollback operation time exceeds limit", 
 PegaAlert="PEGA0004","PEGA0004-Quantity of data received by database query exceeds limit", 
 PegaAlert="PEGA0056","PEGA0056-Defragmentation of the table associated with class System-Locks takes too long",
 1=1,"Google It..") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;-JD&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 13:11:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258460#M176415</guid>
      <dc:creator>JDukeSplunk</dc:creator>
      <dc:date>2016-10-18T13:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Eval replace function not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258461#M176416</link>
      <description>&lt;P&gt;Thanks for response everyone.. None of these are working..  My field values are like "Change Request - HR &amp;amp; Payroll - Time Management (TM)" and "Change Request - Logistics - Materials Management (MM)".. I have to replace part of the string in each field value.. Im able to get this done with rex and sed.. &lt;BR /&gt;
rex field=categories mode=sed "s/Change Request/CR/" |rex field=categories mode=sed "s/Central Functions/CF/"&lt;/P&gt;

&lt;P&gt;But i want to add this as calculated field using eval.. Any ideas on this..? Thanks a lot..&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 04:33:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-replace-function-not-working/m-p/258461#M176416</guid>
      <dc:creator>k_harini</dc:creator>
      <dc:date>2016-10-20T04:33:38Z</dc:date>
    </item>
  </channel>
</rss>

