<?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 globally replace a value in any of the fields. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480587#M134667</link>
    <description>&lt;P&gt;Have you tried &lt;CODE&gt;| replace 0 with "NA" |&lt;/CODE&gt; ?&lt;/P&gt;</description>
    <pubDate>Fri, 28 Feb 2020 18:17:18 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-02-28T18:17:18Z</dc:date>
    <item>
      <title>How to globally replace a value in any of the fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480586#M134666</link>
      <description>&lt;P&gt;i have a output where i have 0 in random columns.&lt;BR /&gt;
i would like these 0's to be replaced with any text for reporting...&lt;/P&gt;

&lt;P&gt;is it possible to replace 0 in any field ? ex output below&lt;/P&gt;

&lt;P&gt;Jan2019 Feb2019 Mar2019 Apr2019&lt;BR /&gt;
0             1               8               10&lt;BR /&gt;
1              20              3                40&lt;BR /&gt;
9              1               0                4&lt;/P&gt;

&lt;P&gt;the above should change to &lt;BR /&gt;
Jan2019 Feb2019 Mar2019 Apr2019&lt;BR /&gt;
NA             1               8               10&lt;BR /&gt;
1              20              3                40&lt;BR /&gt;
9              1               NA                4&lt;/P&gt;

&lt;P&gt;there are also 0's in other cells but they are not =0, but 10 ,40 , 20 etc...&lt;BR /&gt;
but only =0 should be replaced, thanks for the response in advance..&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 17:36:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480586#M134666</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-02-28T17:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to globally replace a value in any of the fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480587#M134667</link>
      <description>&lt;P&gt;Have you tried &lt;CODE&gt;| replace 0 with "NA" |&lt;/CODE&gt; ?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 18:17:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480587#M134667</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-02-28T18:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to globally replace a value in any of the fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480588#M134668</link>
      <description>&lt;P&gt;This will replace the other 0 also to NA, like in 20,40 etc...  and the column names are dynamic...&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 03:46:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480588#M134668</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-03-02T03:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to globally replace a value in any of the fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480589#M134669</link>
      <description>&lt;P&gt;hi @jiaqya, &lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| foreach Jan2019,Feb2019,Mar2019,Apr2019 [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;==0, "NA", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the interested fields contains same string in their names:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| foreach *2019 [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;==0, "NA", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="Jan2019,Feb2019,Mar2019,Apr2019
0,1,8,10
1,20,3,40
9,1,0,4" 
| multikv forceheader=1 
| fields - _time,_raw,linecount 
| foreach Jan2019,Feb2019,Mar2019,Apr2019 
    [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;==0, "NA", &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Mar 2020 05:21:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480589#M134669</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-02T05:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to globally replace a value in any of the fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480590#M134670</link>
      <description>&lt;P&gt;richgalloway's solution will work. replace will not modify values like in 20, 40 etc. That will only happen if you specify &lt;CODE&gt;|replace *0 with "NA"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 05:59:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480590#M134670</guid>
      <dc:creator>anmolpatel</dc:creator>
      <dc:date>2020-03-02T05:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to globally replace a value in any of the fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480591#M134671</link>
      <description>&lt;P&gt;Right, i was trying rex before and it was replacing 0 as NA everywhere it found.&lt;/P&gt;

&lt;P&gt;with replace 0 with "NA" , it is only replacing the 0 , and not the 20/40&lt;BR /&gt;
thanks, this solves my problem.&lt;/P&gt;

&lt;P&gt;john.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 06:58:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480591#M134671</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-03-02T06:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to globally replace a value in any of the fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480592#M134672</link>
      <description>&lt;P&gt;i do have my solution by using replace 0 as NA&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 06:59:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-globally-replace-a-value-in-any-of-the-fields/m-p/480592#M134672</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2020-03-02T06:59:34Z</dc:date>
    </item>
  </channel>
</rss>

