<?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: aggregate count based on multiple conditions in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529170#M4136</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/51838"&gt;@rizwan0683&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;This should do it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|  makeresults 
|  eval foo="1 2 3 2 5 2 1 5"
|  makemv foo
|  mvexpand foo
|  eval foo_counter=if(foo=1 OR foo=2, 1, 0)
|  stats sum(foo_counter) as foo_counter&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;You'll just nned the last 2 lines. The others are just to make up some sample data.&lt;BR /&gt;&lt;BR /&gt;Hope it helps.&lt;BR /&gt;&lt;BR /&gt;BR&lt;BR /&gt;Ralph&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 16:35:40 GMT</pubDate>
    <dc:creator>rnowitzki</dc:creator>
    <dc:date>2020-11-12T16:35:40Z</dc:date>
    <item>
      <title>aggregate count based on multiple conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529168#M4135</link>
      <description>&lt;P&gt;I have an index with events containing a field foo that can carry multiple numeric values 1,2,3&lt;/P&gt;&lt;P&gt;Looking to count all events where foo is either 1 or 2.&lt;/P&gt;&lt;P&gt;have tried couple of options with eval and stats count but not getting there&lt;/P&gt;&lt;P&gt;|stats count (eval(foo=1 OR foo=2)) as Foo_combined&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:25:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529168#M4135</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2020-11-12T16:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate count based on multiple conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529170#M4136</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/51838"&gt;@rizwan0683&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;This should do it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|  makeresults 
|  eval foo="1 2 3 2 5 2 1 5"
|  makemv foo
|  mvexpand foo
|  eval foo_counter=if(foo=1 OR foo=2, 1, 0)
|  stats sum(foo_counter) as foo_counter&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;You'll just nned the last 2 lines. The others are just to make up some sample data.&lt;BR /&gt;&lt;BR /&gt;Hope it helps.&lt;BR /&gt;&lt;BR /&gt;BR&lt;BR /&gt;Ralph&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:35:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529170#M4136</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-11-12T16:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate count based on multiple conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529182#M4137</link>
      <description>&lt;P&gt;thanks that seems to work. can you break down the eval cmd please, what does the 1,0 following foo=2 perform?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF foo=1 or foo=2 then add 1 to the value of foo_counter, else don't add anything (0) ?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 17:31:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529182#M4137</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2020-11-12T17:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate count based on multiple conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529185#M4138</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/51838"&gt;@rizwan0683&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Glad I could help.&lt;BR /&gt;&lt;BR /&gt;To see what it does, just run the query without the last line, like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|  makeresults 
|  eval foo="1 2 3 2 5 2 1 5"
|  makemv foo
|  mvexpand foo
|  eval foo_counter=if(foo=1 OR foo=2, 1, 0)&lt;/LI-CODE&gt;&lt;P&gt;=&amp;gt; As you can see, it adds an field called "&lt;EM&gt;foo_counter&lt;/EM&gt;" to all the rows and evals it to "1" if foo is "1" or&amp;nbsp; "2". The "0" is basically the "else" value, so everything but 1 and 2 will be evaled to 0.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;When you sum &lt;EM&gt;foo_counter&lt;/EM&gt; up (which the &lt;EM&gt;stats&lt;/EM&gt; command does),&amp;nbsp; you get the count of 1s and 2s.&lt;BR /&gt;&lt;BR /&gt;Ralph&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 17:34:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529185#M4138</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-11-12T17:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate count based on multiple conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529188#M4139</link>
      <description>&lt;P&gt;thanks I see the new fields now.&lt;/P&gt;&lt;P&gt;What I need to do next is to chart this along another series (bar), where bar is another field found in the event. I have the following&lt;/P&gt;&lt;P&gt;| eval foo_counter=if(foo=1 OR foo=2, 1, 0)&lt;BR /&gt;| eval bar_counter=if(bar="x",1,0)&lt;BR /&gt;|bin span=1d _time&lt;BR /&gt;|stats count(foo_counter) as Total_Foo count(bar_counter) as Total_Bar by _time&lt;/P&gt;&lt;P&gt;Looking to see the number of foo and bar per day for a period of time. Ideally this would be plotted as overlay chart so Total_Foo as bar chart and Total_Bar as a line chart with its separate y-axis&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 17:56:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529188#M4139</guid>
      <dc:creator>rizwan0683</dc:creator>
      <dc:date>2020-11-12T17:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate count based on multiple conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529210#M4141</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/51838"&gt;@rizwan0683&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I prefer timechart over &lt;EM&gt;bin ... _time&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|  timechart sum(foo_counter) as foos, sum(bar_counter) as bars&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you select "column bar" on the visualization tab -&amp;gt; click on "format" -&amp;gt; "chart overlay" and in the text field at the top you type in "bars".&lt;BR /&gt;&lt;BR /&gt;Now you have &lt;EM&gt;foos&lt;/EM&gt; as columns, overlayed by &lt;EM&gt;bars&lt;/EM&gt; as line chart.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Ralph&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 20:11:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/aggregate-count-based-on-multiple-conditions/m-p/529210#M4141</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-11-12T20:11:59Z</dc:date>
    </item>
  </channel>
</rss>

