<?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: Stats count for multiple fields in search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521906#M147145</link>
    <description>&lt;P&gt;Here's an example - the first part sets up your dataset, then shows how to use stats.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="x,y,z
true,true,false
false,false,true
true,false,true"
| multikv forceheader=1
| table x y z
| stats sum(eval(if(x="true",1,0))) as x sum(eval(if(y="true",1,0))) as y sum(eval(if(z="true",1,0))) as z
| transpose 0 column_name="state" 
| rename "row 1" as count&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 00:32:02 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2020-09-29T00:32:02Z</dc:date>
    <item>
      <title>Stats count for multiple fields in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521901#M147142</link>
      <description>&lt;P&gt;I have a query that has multiple states represented in each log event how do i get stats based on the state values&amp;nbsp;my logs look like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;event 1 : x=true, y=true, z=false&lt;/P&gt;&lt;P&gt;event 2 : x=false, y=false, z=true&lt;/P&gt;&lt;P&gt;event 3: x=true, y= false, z=true&lt;/P&gt;&lt;P&gt;i want track all the scenarios where the values are true for these stages(x, y, z) like.&lt;/P&gt;&lt;P&gt;base_search AND (x=true or y=true or z=true) | stats count by x, y, z&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;state&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;x&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;y&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;z&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Is this possible to chart or do i have to log each state individually ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 00:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521901#M147142</guid>
      <dc:creator>rockybhai</dc:creator>
      <dc:date>2020-09-29T00:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Stats count for multiple fields in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521906#M147145</link>
      <description>&lt;P&gt;Here's an example - the first part sets up your dataset, then shows how to use stats.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="x,y,z
true,true,false
false,false,true
true,false,true"
| multikv forceheader=1
| table x y z
| stats sum(eval(if(x="true",1,0))) as x sum(eval(if(y="true",1,0))) as y sum(eval(if(z="true",1,0))) as z
| transpose 0 column_name="state" 
| rename "row 1" as count&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 00:32:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521906#M147145</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-09-29T00:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Stats count for multiple fields in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521908#M147146</link>
      <description>&lt;P&gt;Each log statement contains only one reference to x,y,z. In your example i see you have loaded all the various states into one string. This will be represented as three messages in my case.&lt;/P&gt;&lt;P&gt;_raw;"setup x=true, y=false, z=false"&lt;BR /&gt;_raw: "setup x=true, y=true, z=false"&lt;BR /&gt;&lt;BR /&gt;so when i search for setup i can get all these logs but not sure how to table these values.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 00:54:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521908#M147146</guid>
      <dc:creator>rockybhai</dc:creator>
      <dc:date>2020-09-29T00:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stats count for multiple fields in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521910#M147147</link>
      <description>&lt;P&gt;The example shows 3 events, this is the part that sets up exactly the data you posted in your original post&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="x,y,z
true,true,false
false,false,true
true,false,true"
| multikv forceheader=1
| table x y z&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and if you run this on its own, you get 3 events, as you posted.&lt;/P&gt;&lt;P&gt;So, the part you need is the stats part&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 01:59:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-count-for-multiple-fields-in-search/m-p/521910#M147147</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-09-29T01:59:12Z</dc:date>
    </item>
  </channel>
</rss>

