<?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: Help creating search to retrieve the results of the sum of Pb + Pb2 + Pb3 classed by name and town in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593187#M12190</link>
    <description>&lt;P&gt;Perfect PickleRick, thanks&lt;/P&gt;</description>
    <pubDate>Sat, 09 Apr 2022 09:50:36 GMT</pubDate>
    <dc:creator>jip31</dc:creator>
    <dc:date>2022-04-09T09:50:36Z</dc:date>
    <item>
      <title>Help creating search to retrieve the results of the sum of Pb + Pb2 + Pb3 classed by name and town</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593134#M12177</link>
      <description>&lt;P&gt;hello&lt;/P&gt;
&lt;P&gt;At the end of this subsearch I would like to be able to retrieve the results of the sum of Pb + Pb2 + Pb3 classed by name and town&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=abc sourcetype=toto
| search rtt &amp;gt; 200 
| stats avg(rtt) as rtt by name town
| eval Pb=if(rtt&amp;gt;200,1,0) 
| search Pb &amp;gt; 0 
| append
    [ search `index=cde sourcetype=tutu 
    | stats avg(logon) as logon by name town 
    | eval Pb2=if(logon&amp;gt;300,1,0) 
    | search Pb2 &amp;gt; 0 ] 
| append
    [ search index=efg sourcetype=titi
    | stats dc(id) as id by name town
    | eval Pb3=if(id&amp;gt;2,1,0)
     search Pb3 &amp;gt;5]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| stats sum(Pb1 + Pb2 + Pb3) by name town
 &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;could you help please?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 15:58:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593134#M12177</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-04-08T15:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating search to retrieve the results of the sum of Pb + Pb2 + Pb3 classed by name and town</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593143#M12179</link>
      <description>&lt;P&gt;You almost had it!&amp;nbsp; Use the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; function within stats.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats sum(eval(Pb1 + Pb2 + Pb3)) by name town&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 17:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593143#M12179</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-04-08T17:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating search to retrieve the results of the sum of Pb + Pb2 + Pb3 classed by name and town</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593173#M12187</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have 2 problems&lt;/P&gt;&lt;P&gt;1) if i use your example, I have the message&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Error in 'stats' command: You must specify a rename for the aggregation specifier on the dynamically evaluated field 'sum(eval(P1 + P2 ))'.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;If i am just doing | eval t=(Pb1+Pb2+Pb3) | stats sum(t) by.... , it works&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;2) When I run the search, the result for "t" field works only if the 3 conditions are true, so my result is always 3&lt;/DIV&gt;&lt;DIV class=""&gt;In the t field, I would like to have 0, 1, 2 or 3&lt;/DIV&gt;&lt;DIV class=""&gt;Here is my search&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`index` 
| search rtt &amp;gt; 200 
| stats avg(rtt) as rtt by name town site 
| eval Pb1=if(rtt&amp;gt;200,1,0) 
| search Pb1 &amp;gt; 0 
| appendcols 
    [ search `index` 
    | stats avg(logon) as logon by name town 
    | eval Pb2=if(logon&amp;gt;30000,1,0) 
    | search Pb2 &amp;gt; 0 ] 
| appendcols 
    [ search `index`  
    | stats dc(id) as id by name town 
    | eval Pb3=if(id&amp;gt;0,1,0) 
    | search Pb3&amp;gt;0
        ] 
| eval t=(Pb1+Pb2+Pb3) 
| stats sum(t) by name town&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2022 07:08:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593173#M12187</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-04-09T07:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating search to retrieve the results of the sum of Pb + Pb2 + Pb3 classed by name and town</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593175#M12188</link>
      <description>&lt;P&gt;Appendcols will cheat you here - there's no guarantee that all three searches will give you your partial results in the same order so the additional columns will most probably not match the earlier results.&lt;/P&gt;&lt;P&gt;But apart from that, let's for now assume that we're using append instead of trying to rework the search into a single one. So starting with your initial search&lt;/P&gt;&lt;PRE&gt;index=abc sourcetype=toto
| search rtt &amp;gt; 200 
| stats avg(rtt) as rtt by name town
| eval Pb=if(rtt&amp;gt;200,1,0) 
| search Pb &amp;gt; 0 
| append
    [ search `index=cde sourcetype=tutu 
    | stats avg(logon) as logon by name town 
    | eval Pb2=if(logon&amp;gt;300,1,0) 
    | search Pb2 &amp;gt; 0 ] 
| append
    [ search index=efg sourcetype=titi
    | stats dc(id) as id by name town
    | eval Pb3=if(id&amp;gt;2,1,0)
     search Pb3 &amp;gt;5]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;We land with some stats having name, town and a field of Pb, Pb2 or Pb3.&lt;/P&gt;&lt;P&gt;So now just create an artificial field from those three:&lt;/P&gt;&lt;PRE&gt;| eval temp = coalesce(Pb,Pb2,Pb3)&lt;/PRE&gt;&lt;P&gt;And sum them up&lt;/P&gt;&lt;PRE&gt;| stats sum(temp) as sum_of_Pbs by name town&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2022 07:22:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593175#M12188</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-09T07:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help creating search to retrieve the results of the sum of Pb + Pb2 + Pb3 classed by name and town</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593187#M12190</link>
      <description>&lt;P&gt;Perfect PickleRick, thanks&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2022 09:50:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-creating-search-to-retrieve-the-results-of-the-sum-of-Pb/m-p/593187#M12190</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-04-09T09:50:36Z</dc:date>
    </item>
  </channel>
</rss>

