<?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: Is there a better way to write EVAL to modify information in a chart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141457#M39190</link>
    <description>&lt;P&gt;Hi kashanky143,&lt;/P&gt;

&lt;P&gt;Look this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart values(Item3Count) by Source 
| eval Item3Count=if(match(source,"item1") OR match(source,"item2") OR match(source,"item4"),0,Item3Count) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Apr 2015 07:17:44 GMT</pubDate>
    <dc:creator>ngatchasandra</dc:creator>
    <dc:date>2015-04-13T07:17:44Z</dc:date>
    <item>
      <title>Is there a better way to write EVAL to modify information in a chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141453#M39186</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I have the query which yields the results i want, but i would like to know if there's a cleaner way to achieve my goal.&lt;/P&gt;

&lt;P&gt;I have the following table &lt;BR /&gt;
Source ------------------------- Item3Count&lt;BR /&gt;
Item1       ----------------------------- 1&lt;BR /&gt;
Item2       -----------------------------  1&lt;BR /&gt;
Item3       -----------------------------  22&lt;BR /&gt;
Item4       -----------------------------  1&lt;/P&gt;

&lt;P&gt;I would like to modify the above table to look like this (should show count value for item3 only)&lt;BR /&gt;
Source ------------------------- Item3Count&lt;BR /&gt;
Item1       ----------------------------- 0&lt;BR /&gt;
Item2       -----------------------------  0&lt;BR /&gt;
Item3       -----------------------------  22&lt;BR /&gt;
Item4       -----------------------------  0&lt;/P&gt;

&lt;P&gt;Currently my query looks like this ... It works but i feel like its too many lines of query to make small modification. Please let me know if there's a better way to write the same query&lt;/P&gt;

&lt;P&gt;| chart values(Item3Count) by Source &lt;BR /&gt;
| eval Item3Count=if(match(source,"item1"),0,Item3Count) &lt;BR /&gt;
| eval Item3Count=if(match(source,"item2"),0,Item3Count) &lt;BR /&gt;
| eval Item3Count=if(match(source,"item4"),0,Item3Count)  &lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Sheshank&lt;/P&gt;</description>
      <pubDate>Sat, 11 Apr 2015 21:28:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141453#M39186</guid>
      <dc:creator>kshanky143</dc:creator>
      <dc:date>2015-04-11T21:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to write EVAL to modify information in a chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141454#M39187</link>
      <description>&lt;P&gt;You really only need one of these for the "item3" row.   The way you're doing it is harder cause you have to match all the other rows.   Better to do the reverse and match only the one you want.  The rest will get zeros when source does not match "item 3".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Item3Count=if(match(source,"item3"),0,Item3Count) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Apr 2015 21:43:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141454#M39187</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2015-04-11T21:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to write EVAL to modify information in a chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141455#M39188</link>
      <description>&lt;P&gt;Do you mean this .. ?  I think u missed '!'&lt;BR /&gt;
| eval Item3Count=if(!match(source,"item3"),0,Item3Count) &lt;/P&gt;</description>
      <pubDate>Sat, 11 Apr 2015 23:05:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141455#M39188</guid>
      <dc:creator>kshanky143</dc:creator>
      <dc:date>2015-04-11T23:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to write EVAL to modify information in a chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141456#M39189</link>
      <description>&lt;P&gt;Oh right.  You want the other way around.  Sorry.&lt;/P&gt;

&lt;P&gt;| eval Item3Count=if(match(source,"item3"),Item3Count,0) &lt;/P&gt;</description>
      <pubDate>Sat, 11 Apr 2015 23:24:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141456#M39189</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2015-04-11T23:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to write EVAL to modify information in a chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141457#M39190</link>
      <description>&lt;P&gt;Hi kashanky143,&lt;/P&gt;

&lt;P&gt;Look this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart values(Item3Count) by Source 
| eval Item3Count=if(match(source,"item1") OR match(source,"item2") OR match(source,"item4"),0,Item3Count) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2015 07:17:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141457#M39190</guid>
      <dc:creator>ngatchasandra</dc:creator>
      <dc:date>2015-04-13T07:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to write EVAL to modify information in a chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141458#M39191</link>
      <description>&lt;P&gt;Hi  kshanky143 &lt;BR /&gt;
You can also use this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    ....|replace 1 with 0 in Item3Count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2015 07:50:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141458#M39191</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2015-04-13T07:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a better way to write EVAL to modify information in a chart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141459#M39192</link>
      <description>&lt;P&gt;Item1, Item2, Item3 can have any value.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 00:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-better-way-to-write-EVAL-to-modify-information-in-a/m-p/141459#M39192</guid>
      <dc:creator>kshanky143</dc:creator>
      <dc:date>2015-04-14T00:49:13Z</dc:date>
    </item>
  </channel>
</rss>

