<?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 columns in query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313772#M163445</link>
    <description>&lt;P&gt;Query :&lt;/P&gt;

&lt;P&gt;splunkquery | table Field1 ,Field2,Field3 &lt;/P&gt;

&lt;P&gt;It will work for Fileld1 as stats count(Field1) by Field1 . but I want it for Field2 and Field3 as well.&lt;/P&gt;

&lt;P&gt;I have used transpose but no luck.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2018 13:16:04 GMT</pubDate>
    <dc:creator>bawan</dc:creator>
    <dc:date>2018-01-22T13:16:04Z</dc:date>
    <item>
      <title>stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313769#M163442</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I have query which is returning below result sets in table :Field1,   Field2,    Field3  are headers and BLANK,NO-BLANK are respective values&lt;/P&gt;

&lt;P&gt;Field1,   Field2,    Field3 &lt;BR /&gt;
BLANK, NO-BLANK,BLANK&lt;BR /&gt;
NO-BLANK,NO-BLANK,BLANK&lt;BR /&gt;
BLANK,NO-BLANK,BLANK&lt;BR /&gt;
NO-BLANK,NO-BLANK,BLANK&lt;BR /&gt;
BLANK,BLANK,BLANK&lt;/P&gt;

&lt;P&gt;i want to show result as :&lt;/P&gt;

&lt;P&gt;COLUMN    BLANK_COUNT NO-BLANK_COUNT&lt;BR /&gt;
Field1            3                             2&lt;BR /&gt;
Field2            1                            4&lt;BR /&gt;
Field3            5                            0&lt;/P&gt;

&lt;P&gt;Please help me to build query to show output in above format.&lt;BR /&gt;
Thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:42:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313769#M163442</guid>
      <dc:creator>bawan</dc:creator>
      <dc:date>2020-09-29T17:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313770#M163443</link>
      <description>&lt;P&gt;Please share your query , meanwhile have you explored the transpose function?&lt;BR /&gt;
    &lt;YOUR search=""&gt; | transpose&lt;/YOUR&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 13:04:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313770#M163443</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2018-01-22T13:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313771#M163444</link>
      <description>&lt;P&gt;Query is :&lt;/P&gt;

&lt;P&gt;splunkqry |  table field1,field2,field3 &lt;BR /&gt;
will show below output :&lt;BR /&gt;
Field1, Field2, Field3 &lt;BR /&gt;
BLANK, NO-BLANK,BLANK&lt;BR /&gt;
NO-BLANK,NO-BLANK,BLANK&lt;BR /&gt;
BLANK,NO-BLANK,BLANK&lt;BR /&gt;
NO-BLANK,NO-BLANK,BLANK&lt;BR /&gt;
BLANK,BLANK,BLANK&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;/P&gt;

&lt;P&gt;as I have around 5000 values for all fields hence can not use transpose after table query. &lt;/P&gt;

&lt;P&gt;| stats count(field1) by field1  will give values for field1 as count for BLANK and NO-BLANK&lt;BR /&gt;
I want count for all fields. I have tried append as well but didn't work.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 13:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313771#M163444</guid>
      <dc:creator>bawan</dc:creator>
      <dc:date>2018-01-22T13:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313772#M163445</link>
      <description>&lt;P&gt;Query :&lt;/P&gt;

&lt;P&gt;splunkquery | table Field1 ,Field2,Field3 &lt;/P&gt;

&lt;P&gt;It will work for Fileld1 as stats count(Field1) by Field1 . but I want it for Field2 and Field3 as well.&lt;/P&gt;

&lt;P&gt;I have used transpose but no luck.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 13:16:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313772#M163445</guid>
      <dc:creator>bawan</dc:creator>
      <dc:date>2018-01-22T13:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313773#M163446</link>
      <description>&lt;P&gt;Hi  @bawan,&lt;BR /&gt;
After much trials and errors i finalised below query....have a look&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;splunkquery&amp;gt; | table Field1 ,Field2,Field3| replace BLANK WITH 1
| transpose| addtotals row* fieldname="BLANK_COUNT"
| replace 1 with BLANK| replace NO-BLANK WITH 1| addtotals row* fieldname="NO-BLANK_COUNT"
| fillnull
| table column BLANK_COUNT NO-BLANK_COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if it helps!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 15:17:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313773#M163446</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-22T15:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313774#M163447</link>
      <description>&lt;P&gt;Give this a shot:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base query
| eval temp=1 
| untable temp column val 
| stats count(eval(val="BLANK")) AS BLANK_COUNT count(eval(val="NO-BLANK")) AS NO-BLANK_COUNT BY column
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jan 2018 15:29:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313774#M163447</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-01-22T15:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313775#M163448</link>
      <description>&lt;P&gt;GREAT.. it works... &lt;/P&gt;

&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 05:25:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313775#M163448</guid>
      <dc:creator>bawan</dc:creator>
      <dc:date>2018-01-23T05:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: stats count for multiple columns in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313776#M163449</link>
      <description>&lt;P&gt;Thanks for your query,&lt;BR /&gt;
It showing correct result for No-blank count but Its not showing for Blank count result. &lt;/P&gt;

&lt;P&gt;As, may be due to some fields don't have values for Blank count.&lt;/P&gt;

&lt;P&gt;I use above solution provided by elliotproebstel.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 05:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-for-multiple-columns-in-query/m-p/313776#M163449</guid>
      <dc:creator>bawan</dc:creator>
      <dc:date>2018-01-23T05:31:04Z</dc:date>
    </item>
  </channel>
</rss>

