<?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: SUM &amp;amp; COUNT from a lookup table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748700#M242033</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/308199"&gt;@Simona11&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart span=1d latest("TOTAL DAILY BAGS") as daily_bags, count as total_alarms
|stats sum(total_alarms) as total_alarms, sum(daily_bags) as total_bags&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1750855842075.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39489i27F3DE067EF0C7D4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1750855842075.png" alt="livehybrid_0-1750855842075.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=8 
| streamstats count as row 
| eval AREA=case(row=1,"1111", row=2,"1111", row=3,"1222", row=4,"1323", row=5,"1323", row=6,"1222", row=7,"1111", row=8,"1323") 
| eval "ALARM DESCRIPTION"=case(row=1,"TRIGGER", row=2,"TRIGGER", row=3,"FAILURE", row=4,"FAILURE", row=5,"HAC", row=6,"FAILURE", row=7,"FAILURE", row=8,"TRIGGER") 
| eval "TOTAL DAILY BAGS"=case(row&amp;lt;=5,18600, row&amp;gt;5,33444) 
| eval TIME=case(row&amp;lt;=5,"2024-03-01", row&amp;gt;5,"2024-02-01") 
| eval _time=strptime(TIME,"%Y-%m-%d") 
| timechart span=1d latest("TOTAL DAILY BAGS") as daily_bags, count as total_alarms 
| stats sum(total_alarms) as total_alarms, sum(daily_bags) as total_bags&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jun 2025 12:50:57 GMT</pubDate>
    <dc:creator>livehybrid</dc:creator>
    <dc:date>2025-06-25T12:50:57Z</dc:date>
    <item>
      <title>SUM &amp; COUNT from a lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748698#M242032</link>
      <description>&lt;P&gt;I have a lookup table with daily records which includes: area, alarm description, date, number of bags per area and for that specific day (repetitive number). There is a timestamp for each alarm, and a bag column repeating the total bags for that day (same number appears multiple times because the same day has multiple alarm rows). I want to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) compute the &lt;EM&gt;&lt;STRONG&gt;total number of bags&lt;/STRONG&gt;&lt;/EM&gt; for the whole 3-month period.&lt;/P&gt;&lt;P&gt;2) compute the &lt;EM&gt;&lt;STRONG&gt;total number of alarm events&lt;/STRONG&gt;&lt;/EM&gt; (counted as total occurrences across 3 months).&lt;/P&gt;&lt;P&gt;What is the best approach in Splunk enterprise to get both in the same final stats result?&lt;/P&gt;&lt;P&gt;Example of scenario:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;AREA&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;ALARM DESCRIPTION&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;TOTAL DAILY BAGS&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;STRONG&gt;TIME&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;1111&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;TRIGGER&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;18600&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;01/03/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;1111&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;TRIGGER&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;18600&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;BR /&gt;01/03/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;1222&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;FAILURE&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;18600&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;BR /&gt;01/03/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;1323&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;FAILURE&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;18600&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;BR /&gt;01/03/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;1323&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;HAC&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;18600&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;BR /&gt;01/03/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;1222&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;FAILURE&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;33444&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;01/02/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;1111&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;FAILURE&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;33444&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;01/02/2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;1323&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;TRIGGER&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;33444&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;01/02/2024&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 25 Jun 2025 12:14:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748698#M242032</guid>
      <dc:creator>Simona11</dc:creator>
      <dc:date>2025-06-25T12:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: SUM &amp; COUNT from a lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748700#M242033</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/308199"&gt;@Simona11&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart span=1d latest("TOTAL DAILY BAGS") as daily_bags, count as total_alarms
|stats sum(total_alarms) as total_alarms, sum(daily_bags) as total_bags&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1750855842075.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39489i27F3DE067EF0C7D4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1750855842075.png" alt="livehybrid_0-1750855842075.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=8 
| streamstats count as row 
| eval AREA=case(row=1,"1111", row=2,"1111", row=3,"1222", row=4,"1323", row=5,"1323", row=6,"1222", row=7,"1111", row=8,"1323") 
| eval "ALARM DESCRIPTION"=case(row=1,"TRIGGER", row=2,"TRIGGER", row=3,"FAILURE", row=4,"FAILURE", row=5,"HAC", row=6,"FAILURE", row=7,"FAILURE", row=8,"TRIGGER") 
| eval "TOTAL DAILY BAGS"=case(row&amp;lt;=5,18600, row&amp;gt;5,33444) 
| eval TIME=case(row&amp;lt;=5,"2024-03-01", row&amp;gt;5,"2024-02-01") 
| eval _time=strptime(TIME,"%Y-%m-%d") 
| timechart span=1d latest("TOTAL DAILY BAGS") as daily_bags, count as total_alarms 
| stats sum(total_alarms) as total_alarms, sum(daily_bags) as total_bags&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 12:50:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748700#M242033</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-06-25T12:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: SUM &amp; COUNT from a lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748701#M242034</link>
      <description>&lt;P&gt;What would be the expected result from your sample data? 8 events and 52044 total bags or something else?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| bin span=1d TIME
| stats count latest("TOTAL DAILY BAGS") as TOTAL_DAILY_BAGS by TIME
| stats sum(count) as total_events sum(TOTAL_DAILY_BAGS) as total_daily_bags&lt;/LI-CODE&gt;&lt;P&gt;If your TIME field is not already the date (as shown in your sample), you may need to bin it first&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 12:50:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748701#M242034</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-06-25T12:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: SUM &amp; COUNT from a lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748703#M242036</link>
      <description>&lt;P&gt;Yes, exactly&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2025 12:47:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748703#M242036</guid>
      <dc:creator>Simona11</dc:creator>
      <dc:date>2025-06-25T12:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: SUM &amp; COUNT from a lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748787#M242056</link>
      <description>&lt;P&gt;Unfortunately it is still not working as I am working with a consistent list of multiple areas, and descriptions. Are there other approaches that I might try out? Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 13:36:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748787#M242056</guid>
      <dc:creator>Simona11</dc:creator>
      <dc:date>2025-06-26T13:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: SUM &amp; COUNT from a lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748823#M242057</link>
      <description>&lt;P&gt;Please provide more examples of the events you are dealing with, and include your desired results, and what you are getting (and why it is not correct)?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jun 2025 17:46:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SUM-amp-COUNT-from-a-lookup-table/m-p/748823#M242057</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-06-26T17:46:21Z</dc:date>
    </item>
  </channel>
</rss>

