<?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: How to use 2 events and calculate in SPL in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741704#M240673</link>
    <description>&lt;P&gt;No they do not relate to each other - I am not sure why this just started happening - anyway the totalCapacity never changes so I could hardcode this value for now until I figure something out.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Mar 2025 14:53:05 GMT</pubDate>
    <dc:creator>LizAndy123</dc:creator>
    <dc:date>2025-03-13T14:53:05Z</dc:date>
    <item>
      <title>How to use 2 events and calculate in SPL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741695#M240668</link>
      <description>&lt;P&gt;So I have in the past used a report which finds a string and then calculates the size left and it came as 1 whole event so was simple.&lt;/P&gt;&lt;P&gt;Now it is coming as 2 events - how do I perform this on the 2 events&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st event&amp;nbsp; - replies with totalCapacity=12323455667&lt;/P&gt;&lt;P&gt;2nd event - replies with usedCapacity=233445&lt;/P&gt;&lt;P&gt;I need to take away the used from the total and report - and this was possible before as it came as just 1 event and I did an eval CapLeft = totalCapacity - usedCapacity and it worked because everything was in the same event.&lt;/P&gt;&lt;P&gt;1 event contained totalCapacity and userCapacity in the same output&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 14:11:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741695#M240668</guid>
      <dc:creator>LizAndy123</dc:creator>
      <dc:date>2025-03-13T14:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 2 events and calculate in SPL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741696#M240669</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/241396"&gt;@LizAndy123&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;is there a common field to use for grouping, e.h. host or transaction_id?&lt;/P&gt;&lt;P&gt;if yes, use it in this way:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| stats 
     values(totalCapacity) AS totalCapacity 
     values(usedCapacity ) AS usedCapacity
     BY common_key
| eval CapLeft = totalCapacity - usedCapacity &lt;/LI-CODE&gt;&lt;P&gt;if for the same common_key you can gave more values, use max or min or avg instead of values as function.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 14:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741696#M240669</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-03-13T14:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 2 events and calculate in SPL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741702#M240672</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/241396"&gt;@LizAndy123&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use &lt;STRONG&gt;stats values(fieldName) as fieldName&amp;nbsp;&lt;/STRONG&gt;with an optional&amp;nbsp;&lt;STRONG&gt;by someOtherField&lt;/STRONG&gt;&amp;nbsp;if you have a field for which each of these relate (e.g. host)&lt;/P&gt;&lt;P&gt;See my example below:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=2 
| streamstats count 
| eval field=IF(count=1,"totalCapacity", "usedCapacity") 
| eval value=json_array_to_mv("[12323455667,233445]")
| eval value=mvindex(value,count-1)
| eval {field}=value
| eval host="abc"
| table host *Capacity
| stats values(totalCapacity) AS totalCapacity, values(usedCapacity) AS usedCapacity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1741876006539.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/38168i00AF40B02B977E93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1741876006539.png" alt="livehybrid_0-1741876006539.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how you get on and consider adding karma to this or any other answer if it has helped.&lt;BR /&gt;Regards&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 14:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741702#M240672</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-03-13T14:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 2 events and calculate in SPL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741704#M240673</link>
      <description>&lt;P&gt;No they do not relate to each other - I am not sure why this just started happening - anyway the totalCapacity never changes so I could hardcode this value for now until I figure something out.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 14:53:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-2-events-and-calculate-in-SPL/m-p/741704#M240673</guid>
      <dc:creator>LizAndy123</dc:creator>
      <dc:date>2025-03-13T14:53:05Z</dc:date>
    </item>
  </channel>
</rss>

