<?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 up multiple fields without using foreach? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367497#M108385</link>
    <description>&lt;P&gt;I am using the below search query which contains multiple fields. All the fields (DATA_MB, INDEX_MB, DB2_INDEX_MB, etc.,) contains size values of a particular DB.&lt;/P&gt;
&lt;P&gt;index=main|timechart span=1w sum(DATA_MB) as datamb, sum(INDEX_MB) as indexmb, sum(DB2_DATA_MB) as db2datamb, sum(DB2_INDEX_MB) as db2indexmb, sum(DB2_LOB_MB) as db2lobmb, sum(DB2_LONG_MB) as db2longmb, sum(DB2_XML_MB) as db2xmlmb by DOMAIN limit=25&lt;/P&gt;
&lt;P&gt;I want all these 7 fields such as datamb, indexmb, db2datamb, etc., to be summed up together and display it in a single field name without using "foreach" clause. Is it possible? (Because I need that final field to be used in another query as a main source value)&lt;/P&gt;
&lt;P&gt;Could anyone please help me on this.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2022 14:57:42 GMT</pubDate>
    <dc:creator>akarivaratharaj</dc:creator>
    <dc:date>2022-08-12T14:57:42Z</dc:date>
    <item>
      <title>How to sum up multiple fields without using foreach?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367497#M108385</link>
      <description>&lt;P&gt;I am using the below search query which contains multiple fields. All the fields (DATA_MB, INDEX_MB, DB2_INDEX_MB, etc.,) contains size values of a particular DB.&lt;/P&gt;
&lt;P&gt;index=main|timechart span=1w sum(DATA_MB) as datamb, sum(INDEX_MB) as indexmb, sum(DB2_DATA_MB) as db2datamb, sum(DB2_INDEX_MB) as db2indexmb, sum(DB2_LOB_MB) as db2lobmb, sum(DB2_LONG_MB) as db2longmb, sum(DB2_XML_MB) as db2xmlmb by DOMAIN limit=25&lt;/P&gt;
&lt;P&gt;I want all these 7 fields such as datamb, indexmb, db2datamb, etc., to be summed up together and display it in a single field name without using "foreach" clause. Is it possible? (Because I need that final field to be used in another query as a main source value)&lt;/P&gt;
&lt;P&gt;Could anyone please help me on this.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 14:57:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367497#M108385</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2022-08-12T14:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367498#M108386</link>
      <description>&lt;P&gt;have you tried - &lt;/P&gt;

&lt;P&gt;index=main|timechart span=1w sum(DATA_MB) as datamb, sum(INDEX_MB) as indexmb, sum(DB2_DATA_MB) as db2datamb, sum(DB2_INDEX_MB) as db2indexmb, sum(DB2_LOB_MB) as db2lobmb, sum(DB2_LONG_MB) as db2longmb, sum(DB2_XML_MB) as db2xmlmb by DOMAIN limit=25 | addtotals col=true row=false&lt;/P&gt;

&lt;P&gt;Ref - &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Addtotals" target="_blank"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Addtotals&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:02:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367498#M108386</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2020-09-29T16:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367499#M108387</link>
      <description>&lt;P&gt;Please try addtotals - &lt;/P&gt;

&lt;PRE&gt;index=main|timechart span=1w sum(DATA_MB) as datamb, sum(INDEX_MB) as indexmb, sum(DB2_DATA_MB) as db2datamb, sum(DB2_INDEX_MB) as db2indexmb, sum(DB2_LOB_MB) as db2lobmb, sum(DB2_LONG_MB) as db2longmb, sum(DB2_XML_MB) as db2xmlmb by DOMAIN limit=25| addtotals&lt;/PRE&gt;

&lt;P&gt;please check addtotals&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Addtotals"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Addtotals&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 07:55:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367499#M108387</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2017-09-27T07:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367500#M108388</link>
      <description>&lt;P&gt;The above query is giving me addition of all "datamb" field values, all "indexmb" field values (&amp;amp; other fields too) for a particular domain. It is showing the results as below:&lt;/P&gt;

&lt;P&gt;_time       datamb: Domain1    datamb: Domain2    indexmb: Domain1    indexmb: Domain2   etc.....&lt;BR /&gt;
2017-06     24                                   45                               20.8                             40&lt;BR /&gt;
2017-07     30.05                             56.4                            25                                 60&lt;BR /&gt;
Total          54.05                             101.4                         45.8                              100 &lt;/P&gt;

&lt;P&gt;But how I need is a variable should hold the sum of all the field values&lt;BR /&gt;
var = datamb+indexmb+db2datamb+db2indexmb+db2lobmb+db2longmb+db2xmlmb &lt;/P&gt;

&lt;P&gt;then at last the sum of that variable should be displayed according to the Domain as below&lt;BR /&gt;
|timechart span=1mon sum(var) as Size by DOMAIN&lt;/P&gt;

&lt;P&gt;_time       Size   Domain&lt;BR /&gt;
2017-06   40      Domain1&lt;BR /&gt;
2017-07    100   Domain2&lt;BR /&gt;
etc.,&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 09:10:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367500#M108388</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2017-09-27T09:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367501#M108389</link>
      <description>&lt;P&gt;I can understand that you want to mask your data, but you need to provide more clarity, this explanation is not clear at all....what is your result looking like and what do you want? Have you tried just using | addtotals?&lt;/P&gt;

&lt;P&gt;this will add a new column to the extreme  right with the summation of all the column field values, is that what you want?&lt;BR /&gt;
Can you just add a screen shot of your output WITHOUT using any addtotals ?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 16:22:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367501#M108389</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2017-09-27T16:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367502#M108390</link>
      <description>&lt;P&gt;Hi Sukisen,&lt;/P&gt;

&lt;P&gt;Basically, I am trying to add all the above mentioned fields' values into one field and that I call as "Size". Then I want to find size difference i.e., delta between two time intervals. For example, Delta = July month's size value - June month's size value.&lt;/P&gt;

&lt;P&gt;As per below query I am getting the attached screenshot &lt;A href="http://C:UsersakarivaratharaPicturessplunk.MHT" target="_blank"&gt;1&lt;/A&gt;:&lt;IMG src="http://C:UsersakarivaratharaPicturessplunk.MHT" alt="alt text" /&gt;&lt;BR /&gt;
index=main|timechart span=1w sum(DATA_MB) as datamb, sum(INDEX_MB) as indexmb, sum(DB2_DATA_MB) as db2datamb, sum(DB2_INDEX_MB) as db2indexmb, sum(DB2_LOB_MB) as db2lobmb, sum(DB2_LONG_MB) as db2longmb, sum(DB2_XML_MB) as db2xmlmb by DOMAIN limit=25&lt;BR /&gt;
Analytic Platform and Financial are the Domains which I used. my query is giving me the size value of each DB for each Domain.&lt;/P&gt;

&lt;P&gt;For calculating the delta value of consolidated size details of all db, I have to add the below query into my current query:&lt;BR /&gt;
| untable _time DOMAIN sum | streamstats current=false window=1 global=false sum(sum) as p_sum by DOMAIN | eval delta=sum-p_sum |stats sum(delta) as Delta by DOMAIN&lt;/P&gt;

&lt;P&gt;Before adding this query, I should have a field which holds the summed up value of all the 7 fields which I mentioned earlier.&lt;BR /&gt;
i.e., var = datamb+indexmb+db2datamb+db2indexmb+db2lobmb+db2longmb+db2xmlmb&lt;/P&gt;

&lt;P&gt;So that I could change my delta query accordingly and add into my old query. My final answer I would get is as per attached example screenshot &lt;A href="http://C:UsersakarivaratharaPicturessplunk1.MHT" target="_blank"&gt;2&lt;/A&gt;:&lt;IMG src="http://C:UsersakarivaratharaPicturessplunk1.MHT" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:02:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367502#M108390</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2020-09-29T16:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367503#M108391</link>
      <description>&lt;P&gt;I guess I am unable to upload the screenshot.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 18:01:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367503#M108391</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2017-09-27T18:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367504#M108392</link>
      <description>&lt;P&gt;I'm not understanding why you can't use &lt;CODE&gt;eval&lt;/CODE&gt;?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main
| timechart span=1w
    sum(DATA_MB) as datamb, sum(INDEX_MB) as indexmb, sum(DB2_DATA_MB) as db2datamb, 
    sum(DB2_INDEX_MB) as db2indexmb, sum(DB2_LOB_MB) as db2lobmb, 
    sum(DB2_LONG_MB) as db2longmb, sum(DB2_XML_MB) as db2xmlmb 
    by DOMAIN limit=25
| eval totalmb = datamb + indexmb + db2datamb + db2indexmb + db2lobmb + db2longmb + db2xmlmb 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Sep 2017 18:59:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367504#M108392</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-27T18:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367505#M108393</link>
      <description>&lt;P&gt;Hi DalJeanis,&lt;/P&gt;

&lt;P&gt;If I use eval for adding all the fields and continue with my delta operation, it is showing no results found. I tried this already.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 02:43:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367505#M108393</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2017-09-28T02:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367506#M108394</link>
      <description>&lt;P&gt;Sorry I was trying the eval clause for addition along with the function "round". so it didnot returned me results. Now I got the answer with eval only.&lt;/P&gt;

&lt;P&gt;Thankyou all for the help.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 05:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367506#M108394</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2017-09-28T05:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367507#M108395</link>
      <description>&lt;P&gt;Thankyou inventsekar for your response.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 05:51:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367507#M108395</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2017-09-28T05:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367508#M108396</link>
      <description>&lt;P&gt;@akarivaratharaj - Great!  Have a great evening/day/whatever time it is there...&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 05:53:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367508#M108396</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-28T05:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367509#M108397</link>
      <description>&lt;P&gt;Thankyou Sukisen1981 for your response&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 05:53:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367509#M108397</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2017-09-28T05:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367510#M108398</link>
      <description>&lt;P&gt;Yeah... wish you the same.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 05:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/367510#M108398</guid>
      <dc:creator>akarivaratharaj</dc:creator>
      <dc:date>2017-09-28T05:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up multiple fields without using foreach</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/609333#M211891</link>
      <description>&lt;P&gt;less typing might be:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart span=1w
    sum(eval(DATA_MB+INDEX_MB+DB2_DATA_MB+DB2_INDEX_MB+DB2_LOB_MB+DB2_LONG_MB+DB2_XML_MB)) as totalmb
    by DOMAIN limit=25&lt;/LI-CODE&gt;&lt;P&gt;if you don't need all the individual sums.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 14:38:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-up-multiple-fields-without-using-foreach/m-p/609333#M211891</guid>
      <dc:creator>esalesap</dc:creator>
      <dc:date>2022-08-12T14:38:32Z</dc:date>
    </item>
  </channel>
</rss>

