<?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 how to sum 2 fields of value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95949#M182485</link>
    <description>&lt;P&gt;Hi, if I have:&lt;/P&gt;

&lt;P&gt;2012-10-16T03:27:05+0000, cCount:0 , lCount:17,&lt;/P&gt;

&lt;P&gt;in an event. How can I cCount + lCount = totalCount?&lt;/P&gt;

&lt;P&gt;Can guide me please. Thank you &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2012 01:27:29 GMT</pubDate>
    <dc:creator>JelianeL</dc:creator>
    <dc:date>2012-10-19T01:27:29Z</dc:date>
    <item>
      <title>how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95949#M182485</link>
      <description>&lt;P&gt;Hi, if I have:&lt;/P&gt;

&lt;P&gt;2012-10-16T03:27:05+0000, cCount:0 , lCount:17,&lt;/P&gt;

&lt;P&gt;in an event. How can I cCount + lCount = totalCount?&lt;/P&gt;

&lt;P&gt;Can guide me please. Thank you &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 01:27:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95949#M182485</guid>
      <dc:creator>JelianeL</dc:creator>
      <dc:date>2012-10-19T01:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95950#M182486</link>
      <description>&lt;P&gt;Add an&lt;/P&gt;

&lt;P&gt;|eval totalCount = cCount + lCount &lt;/P&gt;

&lt;P&gt;to your search.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 02:27:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95950#M182486</guid>
      <dc:creator>reed_kelly</dc:creator>
      <dc:date>2012-10-19T02:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95951#M182487</link>
      <description>&lt;P&gt;Hi thanks for your reply.&lt;/P&gt;

&lt;P&gt;But in my fields there is no totalCount.&lt;/P&gt;

&lt;P&gt;So if I add |eval totalCount = cCount(9) + lCount(11) &lt;/P&gt;

&lt;P&gt;By right, it will display a field totalCount? &lt;/P&gt;

&lt;P&gt;And give me the value 20?&lt;/P&gt;

&lt;P&gt;How should I go about to "declare" totalCount?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 02:32:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95951#M182487</guid>
      <dc:creator>JelianeL</dc:creator>
      <dc:date>2012-10-19T02:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95952#M182488</link>
      <description>&lt;P&gt;The eval command creates the field totalCount if it does not exist. Take a look at the doc on eval:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eval"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It's a good command to take a close look at. Check the Functions for eval and where as well.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 04:31:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95952#M182488</guid>
      <dc:creator>reed_kelly</dc:creator>
      <dc:date>2012-10-19T04:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95953#M182489</link>
      <description>&lt;P&gt;Also, the addtotals command may help you:&lt;/P&gt;

&lt;P&gt;...|addtotals fieldname=totalCount *Count&lt;/P&gt;

&lt;P&gt;If it would help you in learning Splunk commands, check out my Quizlet set on Search Commands:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://quizlet.com/11171217/splunk-search-commands-flash-cards/"&gt;http://quizlet.com/11171217/splunk-search-commands-flash-cards/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 04:46:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95953#M182489</guid>
      <dc:creator>reed_kelly</dc:creator>
      <dc:date>2012-10-19T04:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95954#M182490</link>
      <description>&lt;P&gt;Thank you for your links =D will take a look at it.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 06:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95954#M182490</guid>
      <dc:creator>JelianeL</dc:creator>
      <dc:date>2012-10-19T06:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95955#M182491</link>
      <description>&lt;P&gt;Thanks to you, I solved my previous problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Another question with ---&amp;gt; max(totalCount)&lt;/P&gt;

&lt;P&gt;How do I display it together with other fields?&lt;/P&gt;

&lt;P&gt;Currently only return totalCount.&lt;/P&gt;

&lt;P&gt;I tried by message, it does give me message but it returns me all the events.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 08:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95955#M182491</guid>
      <dc:creator>JelianeL</dc:creator>
      <dc:date>2012-10-19T08:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95956#M182492</link>
      <description>&lt;P&gt;Continuing from your last comment...&lt;/P&gt;

&lt;P&gt;If you just want the max totalCount, then you can use the stats command. Combined with above:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  |eval totalCount = cCount + lCount |stats max(totalCount)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want all the rows that you had previously, then you can tack it on with eventstats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |eval totalCount = cCount + lCount 
 |eventstats max(totalCount) as maxTotal 
 |table cCount, lCount, totalCount, maxTotal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to single out the row with the max:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  |eval totalCount = cCount + lCount 
  |eventstats max(totalCount) as maxTotal 
  |where totalCount = maxTotal
  |table cCount, lCount, totalCount, maxTotal
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Oct 2012 11:27:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95956#M182492</guid>
      <dc:creator>reed_kelly</dc:creator>
      <dc:date>2012-10-19T11:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95957#M182493</link>
      <description>&lt;P&gt;Nice addition...  Very thoughtful..  Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 16:55:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95957#M182493</guid>
      <dc:creator>rbardonetorian</dc:creator>
      <dc:date>2016-03-02T16:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95958#M182494</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a similar question, but the awnser does not fit to me. In my case I have a list of all server sessions state:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"User Sessions" =25, /  "Active Sessions"=10  /  "Disconnected Sessions"=14 / "Idle Sessions"=1 / "Other Sessions"=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I add the line to my search:&lt;BR /&gt;
| eval totalCount = "Disconnected_Sessions" + "Idle_Sessions" + "Other_Sessions"&lt;/P&gt;

&lt;P&gt;the result is:&lt;/P&gt;

&lt;P&gt;"User Sessions" =25, &lt;BR /&gt;
"Active Sessions"=10&lt;BR /&gt;&lt;BR /&gt;
total_disconnect=   Disconnected_SessionsIdle_SessionsOther_Sessions&lt;/P&gt;

&lt;P&gt;query:&lt;BR /&gt;
index=app_servers sourcetype="Computers"&lt;BR /&gt;
| eval totalCount = "Disconnected_Sessions" + "Idle_Sessions" + "Other_Sessions"&lt;BR /&gt;
| table  "User Sessions", "Active Sessions",totalCount,  "Disconnected Sessions", "Idle Sessions", "Other Sessions",  "Name" &lt;/P&gt;

&lt;P&gt;Basically, it concatenates the name of the fields . Can someone point me to the right direction?&lt;/P&gt;

&lt;P&gt;Thanks!!!!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:55:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95958#M182494</guid>
      <dc:creator>fariapm1</dc:creator>
      <dc:date>2020-09-29T16:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95959#M182495</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Found the solution:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval totalCount = 'Disconnected Sessions' + 'Idle Sessions' + 'Other Sessions'&lt;/LI-CODE&gt;
&lt;P&gt;The problem was that the field name has a space, and to sum I need to use single quotes.&lt;/P&gt;
&lt;P&gt;User Sessions Active Sessions totalCount&lt;BR /&gt;39 26 13&lt;BR /&gt;&lt;BR /&gt;13 12 1&lt;BR /&gt;&lt;BR /&gt;18 13 5&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 13:05:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95959#M182495</guid>
      <dc:creator>fariapm1</dc:creator>
      <dc:date>2024-01-15T13:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum 2 fields of value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95960#M182496</link>
      <description>&lt;P&gt;Thanks !!! This answer also fits my question. Neither double quotes nor zero quotes, but single quotes can do the correct number sum and return the correct values. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 10:23:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-sum-2-fields-of-value/m-p/95960#M182496</guid>
      <dc:creator>kimikoyan</dc:creator>
      <dc:date>2018-09-05T10:23:05Z</dc:date>
    </item>
  </channel>
</rss>

