<?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 values from multiple arrays in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528118#M149102</link>
    <description>&lt;P data-unlink="true"&gt;1_month_last_day_prior,2_month_last_day_prior - are these existing field values (e.g.&amp;nbsp;&lt;SPAN&gt;| eval {aName}=aValue&lt;/SPAN&gt;&amp;nbsp;) or a new variable?&lt;/P&gt;&lt;P&gt;If it's a new variable, you dont need the { } brackets around them&lt;/P&gt;&lt;P&gt;If it's an existing field value as mentioned in&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.0/SearchReference/Eval#Field_names" target="_self"&gt;Eval Field_names&lt;/A&gt;&amp;nbsp;, then it will not work in this way&lt;/P&gt;</description>
    <pubDate>Thu, 05 Nov 2020 13:50:53 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2020-11-05T13:50:53Z</dc:date>
    <item>
      <title>Adding values from multiple arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528099#M149094</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to add the values from 2 array functions to get the overall sum.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval {1_month_last_day_prior} = case((StartDateEpoch &amp;lt; '1_month_last_day_prior_epoch') AND (StartDateEpoch &amp;gt; '2_month_last_day_prior_epoch'), additionalBillingRate2,
StartDateEpoch &amp;gt; '1_month_last_day_prior_epoch', "0",1=1,MRR)

| eval {2_month_last_day_prior} = case((StartDateEpoch &amp;lt; '2_month_last_day_prior_epoch') AND (StartDateEpoch &amp;gt; '3_month_last_day_prior_epoch'), additionalBillingRate2,
StartDateEpoch &amp;gt; '2_month_last_day_prior_epoch', "0",1=1,MRR)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;The below is not working and im not sure what syntax I should be using:&lt;BR /&gt;&lt;BR /&gt;| eval sum='{1_month_last_day_prior}' + '{2_month_last_day_prior}'&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 12:37:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528099#M149094</guid>
      <dc:creator>shonac</dc:creator>
      <dc:date>2020-11-05T12:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values from multiple arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528118#M149102</link>
      <description>&lt;P data-unlink="true"&gt;1_month_last_day_prior,2_month_last_day_prior - are these existing field values (e.g.&amp;nbsp;&lt;SPAN&gt;| eval {aName}=aValue&lt;/SPAN&gt;&amp;nbsp;) or a new variable?&lt;/P&gt;&lt;P&gt;If it's a new variable, you dont need the { } brackets around them&lt;/P&gt;&lt;P&gt;If it's an existing field value as mentioned in&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.0/SearchReference/Eval#Field_names" target="_self"&gt;Eval Field_names&lt;/A&gt;&amp;nbsp;, then it will not work in this way&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 13:50:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528118#M149102</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-11-05T13:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values from multiple arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528122#M149105</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/136781"&gt;@renjith_nair&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;These are existing fields I have created here:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval 1_month_last_day_prior=strftime(relative_time('billDateEpoch' ,"@mon-1d"), "%Y-%m-%d")
| eval 2_month_last_day_prior=strftime(relative_time('billDateEpoch' ,"-1mon@mon-1d"), "%Y-%m-%d")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any other way I could add the values?&lt;/P&gt;&lt;P&gt;This is how the results look currently, trying to add the 3 values.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shonac_0-1604584975069.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11662i75594B807BEA77A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shonac_0-1604584975069.png" alt="shonac_0-1604584975069.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 14:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528122#M149105</guid>
      <dc:creator>shonac</dc:creator>
      <dc:date>2020-11-05T14:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values from multiple arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528126#M149106</link>
      <description>&lt;P&gt;If you just want to add those row values and create a new field , just add this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| addtotals row=t&lt;/LI-CODE&gt;&lt;P&gt;or just lets know the expected output.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 14:12:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528126#M149106</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-11-05T14:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values from multiple arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528143#M149111</link>
      <description>&lt;P&gt;The issue with this is I have other values in each row, but I only want to sum the first 3 dates:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shonac_0-1604588546329.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11663iDD2A425355FA4E01/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shonac_0-1604588546329.png" alt="shonac_0-1604588546329.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 15:03:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528143#M149111</guid>
      <dc:creator>shonac</dc:creator>
      <dc:date>2020-11-05T15:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values from multiple arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528149#M149116</link>
      <description>&lt;P&gt;Is it always the first 3 dates ? You may use &lt;EM&gt;foreach&amp;nbsp;&amp;nbsp;&lt;/EM&gt;with some conditions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your search|eval total=0,count=0
|foreach 20* [eval total=if(count &amp;lt; 3,total+&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,total+0)|eval count=count+1]&lt;/LI-CODE&gt;&lt;P&gt;Is it possible to share your current search , you may mask sensitive information if any&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 15:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528149#M149116</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-11-05T15:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values from multiple arrays</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528177#M149124</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/136781"&gt;@renjith_nair&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It will always be the first 3 dates I need to add as these are for the prior period (PPadjustment).&lt;BR /&gt;This is my full search, apologies it is extremely long.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputcsv gen_billable_conns.csv
| search Client="*"
| lookup gen_billing_discount_rates.csv ClientName as Client OUTPUT Premium, Discount
| fillnull value=1 Premium, Discount
| eval StartDateEpoch=strptime('Client Handover Date', "%Y-%m-%d"), DecomDateEpoch=strptime('Decommission Date', "%Y-%m-%d")
| eval StartYear=strftime(StartDateEpoch, "%Y"), StartMonth=strftime(StartDateEpoch, "%b"), StartDay=strftime(StartDateEpoch, "%d"), DecomYear=strftime(DecomDateEpoch, "%Y"), DecomMonth=strftime(DecomDateEpoch, "%b"), DecomDay=strftime(DecomDateEpoch,"%d")
| eval billingDate="01-10-2020", billDateEpoch=strptime(billingDate, "%d-%m-%Y")
| eval jiraMRR=MRR

| eval 1_month_last_day=strftime(relative_time('billDateEpoch' ,"@mon-1d"), "%d")
| eval 2_month_last_day=strftime(relative_time('billDateEpoch' ,"-1mon@mon-1d"), "%d")
| eval 3_month_last_day=strftime(relative_time('billDateEpoch' ,"-2mon@mon-1d"), "%d")

| eval totalDaysInPreviousQuarter='1_month_last_day'+'2_month_last_day'+'3_month_last_day'
| eval daysBetweenHandoverAndBill=round((billDateEpoch-StartDateEpoch)/60/60/24, 0), daysBetweenDecomAndBill=round((billDateEpoch-DecomDateEpoch)/60/60/24, 0)

| eval adjustedMRR=if(daysBetweenHandoverAndBill&amp;lt;=365, MRR*Premium, MRR*Discount)
| eval adjustedBillingRate=exact(adjustedMRR*3)
| eval requiresAdjustedMRR=if('Deviation from Base MRR'="Yes", "Yes", "No")
| eval MRR=if(requiresAdjustedMRR="Yes", adjustedMRR, MRR)
| eval DRR=(MRR*3/totalDaysInPreviousQuarter)
| eval normalBillingRate=exact(MRR*3)
| eval additionalBillingRate=exact((DRR*daysBetweenHandoverAndBill)+NRR)
| eval billingCredit=exact(DRR*daysBetweenDecomAndBill)

| eval requiresAdditionalBillingRate=if(daysBetweenHandoverAndBill &amp;lt;= totalDaysInPreviousQuarter, "Yes", "No")
| eval requiresBillingCredit=if(daysBetweenDecomAndBill &amp;lt;= totalDaysInPreviousQuarter, "Yes", "No")

| eval billingCharge=if(requiresAdditionalBillingRate="Yes", (normalBillingRate+additionalBillingRate), normalBillingRate)
| eval billingCharge=if(requiresAdjustedMRR="Yes" AND requiresAdditionalBillingRate="Yes", (adjustedBillingRate+additionalBillingRate), 'billingCharge')
| eval billingCharge=if(billingCredit&amp;gt;0, 0,'billingCharge')
| fillnull value=0 billingCredit
| eval QCharge=billingCharge-billingCredit
| eval NRR=if(requiresAdditionalBillingRate="Yes", NRR, 0)
| rename billingCharge as quarterlyCharge, billingCredit as quarterlyCredit, QCharge as totalCost

| eval 1_month_last_day_prior=strftime(relative_time('billDateEpoch' ,"@mon-1d"), "%Y-%m-%d")
| eval 2_month_last_day_prior=strftime(relative_time('billDateEpoch' ,"-1mon@mon-1d"), "%Y-%m-%d")
| eval 3_month_last_day_prior=strftime(relative_time('billDateEpoch' ,"-2mon@mon-1d"), "%Y-%m-%d")
| eval 1_month_last_day_current=strftime(relative_time(billDateEpoch,"+1mon@mon-1d"), "%Y-%m-%d") 
| eval 2_month_last_day_current=strftime(relative_time(billDateEpoch,"+2mon@mon-1d"), "%Y-%m-%d") 
| eval 3_month_last_day_current=strftime(relative_time(billDateEpoch,"+3mon@mon-1d"), "%Y-%m-%d")

| eval 1_month_last_day_prior_epoch=relative_time('billDateEpoch' ,"@mon-1d")
| eval 2_month_last_day_prior_epoch=relative_time('billDateEpoch' ,"-1mon@mon-1d") 
| eval 3_month_last_day_prior_epoch=relative_time('billDateEpoch' ,"-2mon@mon-1d")
| eval 4_month_last_day_prior_epoch=relative_time('billDateEpoch' ,"-3mon@mon-1d")
| eval 1_month_last_day_current_epoch=relative_time(billDateEpoch,"+1mon@mon-1d")
| eval 2_month_last_day_current_epoch=relative_time(billDateEpoch,"+2mon@mon-1d")
| eval 3_month_last_day_current_epoch=relative_time(billDateEpoch,"+3mon@mon-1d")
| eval 4_month_last_day_current_epoch=relative_time(billDateEpoch,"+4mon@mon-1d")
| eval start_month_last_day_epoch=relative_time(StartDateEpoch,"+1mon@mon-1d") 
| eval decom_month_last_day_epoch=relative_time(StartDateEpoch,"+1mon@mon-1d") 

| eval daysBetweenHandoverAndEOM=round(('start_month_last_day_epoch'-StartDateEpoch)/60/60/24, 0), daysBetweenDecomAndEOM=round(('decom_month_last_day_epoch'-DecomDateEpoch)/60/60/24, 0)
| eval additionalMonthlyRate=round((DRR*daysBetweenHandoverAndEOM),2), creditMonthlyRate=round((DRR*daysBetweenDecomAndEOM),2)

| eval {1_month_last_day_prior} = case((StartDateEpoch &amp;lt; '1_month_last_day_prior_epoch') AND (StartDateEpoch &amp;gt; '2_month_last_day_prior_epoch'), additionalMonthlyRate,
StartDateEpoch &amp;gt; '1_month_last_day_prior_epoch', "0",1=1,MRR)
| eval {2_month_last_day_prior} = case((StartDateEpoch &amp;lt; '2_month_last_day_prior_epoch') AND (StartDateEpoch &amp;gt; '3_month_last_day_prior_epoch'), additionalMonthlyRate,
StartDateEpoch &amp;gt; '2_month_last_day_prior_epoch', "0",1=1,MRR)
| eval {3_month_last_day_prior} = case((StartDateEpoch &amp;lt; '3_month_last_day_prior_epoch') AND (StartDateEpoch &amp;gt; '4_month_last_day_prior_epoch'), additionalMonthlyRate,
StartDateEpoch &amp;gt; '3_month_last_day_prior_epoch', "0",1=1,MRR)

| eval {1_month_last_day_current} = case((StartDateEpoch &amp;lt; '1_month_last_day_current_epoch') AND (StartDateEpoch &amp;gt; '1_month_last_day_prior_epoch'), additionalMonthlyRate,
StartDateEpoch &amp;gt; '1_month_last_day_current_epoch', "0",1=1,MRR)
| eval {2_month_last_day_current} = case((StartDateEpoch &amp;lt; '2_month_last_day_current_epoch') AND (StartDateEpoch &amp;gt; '1_month_last_day_current_epoch'), additionalMonthlyRate,StartDateEpoch &amp;gt; '2_month_last_day_current_epoch', "0",1=1,MRR)
| eval {3_month_last_day_current} = case((StartDateEpoch &amp;lt; '3_month_last_day_current_epoch') AND (StartDateEpoch &amp;gt; '2_month_last_day_current_epoch'), additionalMonthlyRate,StartDateEpoch &amp;gt; '3_month_last_day_current_epoch', "0",1=1,MRR)

| table "Circuit ID", Key, Summary, "Billing Notes", NRR, MRR, "Client Handover Date", "Decommission Date", quarterlyCharge, quarterlyCredit, totalCost, Currency, PPadjustment, 20*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 17:07:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-values-from-multiple-arrays/m-p/528177#M149124</guid>
      <dc:creator>shonac</dc:creator>
      <dc:date>2020-11-05T17:07:32Z</dc:date>
    </item>
  </channel>
</rss>

