<?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: Adding two field values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90130#M23121</link>
    <description>&lt;P&gt;I know it has been some time since you posted this, but were you able to find a solution? Or does anyone else know an answer to this? I am facing the same problem.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Apr 2015 08:00:05 GMT</pubDate>
    <dc:creator>SilviaGebel</dc:creator>
    <dc:date>2015-04-16T08:00:05Z</dc:date>
    <item>
      <title>Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90124#M23115</link>
      <description>&lt;P&gt;I have been unable to add two field values and use the new value of a new column&lt;/P&gt;

&lt;P&gt;I'm trying to take one field, multiply it by .60 then add that to another field that has been multiplied by .40.  This is how I thought it would be created:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval NewValue=(FirstValue*.60)+(SecondValue*.40)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've verified that: &lt;CODE&gt;| stats values(FirstValue) |&lt;/CODE&gt; and &lt;CODE&gt;| stats values(SecondValue) |&lt;/CODE&gt; print out expected results&lt;/P&gt;

&lt;P&gt;I've also verified that I am able to do &lt;CODE&gt;|eval NewValue1=(FirstValue*.60) |&lt;/CODE&gt; and &lt;CODE&gt;| eval NewValue2=(SecondValue*.60)&lt;/CODE&gt; | both yielding results.  However, when I try: &lt;CODE&gt;| eval NewValue=(FirstValue+SecondValue)&lt;/CODE&gt; I get nothing.&lt;/P&gt;

&lt;P&gt;Any ideas/thoughts?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2011 22:17:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90124#M23115</guid>
      <dc:creator>mbolostk</dc:creator>
      <dc:date>2011-10-11T22:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90125#M23116</link>
      <description>&lt;P&gt;It doesn't make sense why this would not work.  It could be a misspelling or a CamelCaseProblem.  I did a simple comparison search on my Splunk test instance:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source="*metrics.log" per_source_thruput 
| eval foo=exact(kb*.60)
| eval foo2=exact(kb * .5) 
| eval foo3=foo+foo2 
| eval foo4=exact(kb*.60)+exact(kb*.50) 
| eval error=abs(foo4-foo3) 
| table kb,foo,foo2,foo3,foo4,error
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This computes the value of &lt;CODE&gt;(kb * .6) + (kb * .5)&lt;/CODE&gt; both stepwise and as a single expression, and compares the results.  There was occasionally rounding error in the least significant digit, which should be expected with floating point.&lt;/P&gt;

&lt;P&gt;Note, however, the use of &lt;CODE&gt;exact()&lt;/CODE&gt; to make sure the various subexpressions were processed with floating point (instead of integer) maths.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2011 23:25:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90125#M23116</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-10-11T23:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90126#M23117</link>
      <description>&lt;P&gt;Maybe a 2nd eye will help me see it.  Here is that part:&lt;/P&gt;

&lt;P&gt;eval IE_Average=(IE_Response*.60) | eval FF_Average=(FF_Response*.40) | eval Averages=(IE_Average)+(FF_Average) | stats values(IE_Response) values(FF_Response) values(IE_Average) values(FF_Average) values(Averages) by test_name &lt;/P&gt;

&lt;P&gt;values(FF_Average) displays column fine&lt;BR /&gt;
values(IE_Average) displays column fine&lt;/P&gt;

&lt;P&gt;But values(Averages) displays nothing....&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:58:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90126#M23117</guid>
      <dc:creator>mbolostk</dc:creator>
      <dc:date>2020-09-28T09:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90127#M23118</link>
      <description>&lt;P&gt;Actually, I don't see anything obvious.  Unfortunately, the answers site is somewhat messing up your comments (and your question) by taking the &lt;CODE&gt;*&lt;/CODE&gt; and treating it like the beginning of &lt;EM&gt;italics&lt;/EM&gt; markup.  &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;  But, a question - could stats be messing this up somehow?  Try this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval IE_Average=(IE_Response * .60) 
| eval FF_Average=(FF_Response * .40) 
| eval Averages=(IE_Average)+(FF_Average) 
| table IE_Response,FF_Response,IE_Average,FF_Average,Averages
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2011 02:13:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90127#M23118</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-10-13T02:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90128#M23119</link>
      <description>&lt;P&gt;This is part of a much larger query. When I use table, it switches the order of the columns and displays nothing but the column not related to this part of the query.  Any other thoughts/ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2011 21:17:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90128#M23119</guid>
      <dc:creator>mbolostk</dc:creator>
      <dc:date>2011-10-13T21:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90129#M23120</link>
      <description>&lt;P&gt;Understood.  The swap to &lt;CODE&gt;table&lt;/CODE&gt; in lieu of &lt;CODE&gt;stats&lt;/CODE&gt; was to enable testing your search in smaller chunks and see if the problem was related to &lt;CODE&gt;stats&lt;/CODE&gt; or not.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2011 23:36:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90129#M23120</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-10-13T23:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90130#M23121</link>
      <description>&lt;P&gt;I know it has been some time since you posted this, but were you able to find a solution? Or does anyone else know an answer to this? I am facing the same problem.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2015 08:00:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90130#M23121</guid>
      <dc:creator>SilviaGebel</dc:creator>
      <dc:date>2015-04-16T08:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90131#M23122</link>
      <description>&lt;P&gt;How did you verify the result of eval NewValue1=(FirstValue*.60)'s result? As eval doesn't printing out the result. then how can you say that you got the right result?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 21:16:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90131#M23122</guid>
      <dc:creator>neeldesai1992</dc:creator>
      <dc:date>2017-10-11T21:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90132#M23123</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| eval NewValue = FirstValue*.60
| eval NewValue = SecondValue*.40
| chart count by NewValue
| eventstats sum(count) as total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps, please comment if you have any questions.Thanks! &lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 23:31:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90132#M23123</guid>
      <dc:creator>sandeepmakkena</dc:creator>
      <dc:date>2019-10-15T23:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90133#M23124</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=FirstValue mode=sed "s/^\s*// s/\s*$//"
| rex field=SecondValue mode=sed "s/^\s*// s/\s*$//"
| eval NewValue = (tonumber(FirstValue) * 0.60) + (tonumber(SecondValue) * 0.40)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 01:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-field-values/m-p/90133#M23124</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-16T01:03:29Z</dc:date>
    </item>
  </channel>
</rss>

