<?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: Multiple clause table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571142#M199029</link>
    <description>&lt;P&gt;Rich, your solutions are always fantastic and well explained. I appreciate the extra explanation because it helps me see where I went wrong.&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 15:55:17 GMT</pubDate>
    <dc:creator>Brainstorms</dc:creator>
    <dc:date>2021-10-15T15:55:17Z</dc:date>
    <item>
      <title>Multiple clause table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571119#M199019</link>
      <description>&lt;P&gt;Hey all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got a really helpful response last time and now I'm back with another question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a search with the same sourcetype that I want to run multiple clauses against to return different results in a table for comparison. Example:&lt;BR /&gt;&lt;BR /&gt;sourcetype = xyz&lt;BR /&gt;| where (color == "red" OR color == "blue" OR color == "purple" OR color == "green") AND (crayon == "crayola" OR crayon == "prisma" OR crayon == "offBrand" OR crayon == "brandA")&lt;BR /&gt;|&amp;nbsp; some stuff here that matches the search to a lookup&lt;BR /&gt;| stats count(name) as "All sets" by Type&amp;nbsp;&lt;EM&gt;(say name and type is the information pulled from the lookup)&lt;/EM&gt;&lt;BR /&gt;| where (color == "red" OR color == "blue) AND (crayon != "crayola" AND crayon != "offBrand")&lt;BR /&gt;| stats count(name) as "Set A" by Type&lt;BR /&gt;| where (color == "red" OR color == "blue) AND (crayon != "prisma" AND crayon != "brandA")&lt;BR /&gt;| stats count(name) as "Set B" by Type&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The end result I want is this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;All sets&lt;/TD&gt;&lt;TD&gt;Set A&lt;/TD&gt;&lt;TD&gt;Set B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;5&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know it's bad practice to use join and append. I also know the where clauses are supposed to be higher up. I'm just not sure how to achieve this.&lt;/P&gt;&lt;P&gt;I can get the 'All sets' just fine of course but after that nothing works.&lt;/P&gt;&lt;P&gt;Any help for this newbie would be much appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 14:25:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571119#M199019</guid>
      <dc:creator>Brainstorms</dc:creator>
      <dc:date>2021-10-15T14:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple clause table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571124#M199023</link>
      <description>&lt;P&gt;Given that all your counts are based on the presence of state (from the lookup), you could do something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=200
| eval state=if(random()%2=0,"state",null())
| eval colour=mvindex(split("red,blue,purple,green",","),random()%4)
| eval crayon=mvindex(split("crayola,prisma,offBrand,brandA",","),random()%4)




| eval setA=if((colour == "red" OR colour == "blue") AND (crayon != "crayola" AND crayon != "offBrand"),1,0)
| eval setB=if((colour == "red" OR colour == "blue") AND (crayon != "prisma" AND crayon != "brandA"),1,0)
| where isnotnull(state)
| stats count as allsets sum(setA) as setA sum(setB) as setB&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 15 Oct 2021 15:03:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571124#M199023</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-15T15:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple clause table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571137#M199027</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command transforms the data so that only named fields are present.&amp;nbsp; That means the color and crayon fields are not available to subsequent &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; commands.&lt;/P&gt;&lt;P&gt;Also, the &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; command discards events, which means the second &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; will throw out all "prisma" crayons leaving none for the last &lt;FONT face="courier new,courier"&gt;where&lt;/FONT&gt; to find.&lt;/P&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command can compute more than one statistic at a time and has an &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; function available to handle complex expressions.&lt;/P&gt;&lt;P&gt;See if this helps&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype = xyz color IN ("red", "blue", "purple", "green") AND crayon IN ("crayola", "prisma", "offBrand", "brandA")
|  some stuff here that matches the search to a lookup
| stats count(name) as "All sets", sum(eval((color == "red" OR color == "blue) AND (crayon != "crayola" AND crayon != "offBrand"))) as "Set A", sum(eval((color == "red" OR color == "blue) AND (crayon != "prisma" AND crayon != "brandA"))) as "Set B" by Type&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 15:32:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571137#M199027</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-10-15T15:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple clause table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571142#M199029</link>
      <description>&lt;P&gt;Rich, your solutions are always fantastic and well explained. I appreciate the extra explanation because it helps me see where I went wrong.&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 15:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-clause-table/m-p/571142#M199029</guid>
      <dc:creator>Brainstorms</dc:creator>
      <dc:date>2021-10-15T15:55:17Z</dc:date>
    </item>
  </channel>
</rss>

