<?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 How would I create a Table using stats within stats? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613548#M50322</link>
    <description>&lt;P&gt;Hello-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to make a table and hopefully be able to integrate it into a dashboard.&lt;/P&gt;
&lt;P&gt;Goal is to interrogate on two fields and pull stats accordingly.&lt;/P&gt;
&lt;P&gt;FieldA has multiple values- table is to show all values of FieldA. Utilize stats count for how many daily transactions have been processed by each unique value of FieldA.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the portion I am having difficulties with- with the daily count for each unique value of FieldA, I want to interrogate that count by FieldB to see how many of that count is a hit for any value of FieldB.&lt;/P&gt;
&lt;P&gt;This is the code I am using:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;table FieldA FieldB | fields "FieldB", "FieldA " | fields "FieldB", "FieldA " | stats count by FieldA , FieldB| sort -"count"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second count of FieldB hits out of the count of FieldA instances is always showing up as zero, despite having values other than zero in FieldB. FieldB values should all be numeric.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Sep 2022 15:38:05 GMT</pubDate>
    <dc:creator>Mena</dc:creator>
    <dc:date>2022-09-19T15:38:05Z</dc:date>
    <item>
      <title>How would I create a Table using stats within stats?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613548#M50322</link>
      <description>&lt;P&gt;Hello-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to make a table and hopefully be able to integrate it into a dashboard.&lt;/P&gt;
&lt;P&gt;Goal is to interrogate on two fields and pull stats accordingly.&lt;/P&gt;
&lt;P&gt;FieldA has multiple values- table is to show all values of FieldA. Utilize stats count for how many daily transactions have been processed by each unique value of FieldA.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the portion I am having difficulties with- with the daily count for each unique value of FieldA, I want to interrogate that count by FieldB to see how many of that count is a hit for any value of FieldB.&lt;/P&gt;
&lt;P&gt;This is the code I am using:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;table FieldA FieldB | fields "FieldB", "FieldA " | fields "FieldB", "FieldA " | stats count by FieldA , FieldB| sort -"count"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second count of FieldB hits out of the count of FieldA instances is always showing up as zero, despite having values other than zero in FieldB. FieldB values should all be numeric.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 15:38:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613548#M50322</guid>
      <dc:creator>Mena</dc:creator>
      <dc:date>2022-09-19T15:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Table- stats within stats</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613554#M50326</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/249592"&gt;@Mena&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;let me understand:&lt;/P&gt;&lt;P&gt;do you want to have in a single table the count of each value of fieldA and the count&amp;nbsp;of each value of fieldB, is it correct?,&lt;/P&gt;&lt;P&gt;in your search you have the count of both count of FieldA and FieldB and probably the values of these fields don't match.&lt;/P&gt;&lt;P&gt;My first hint is to create two different tables one for FieldA and one for FieldB.&lt;/P&gt;&lt;P&gt;But anyway, if you want one table you could try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| stats count AS CountA BY FieldA
| append [ search
   &amp;lt;your_search&amp;gt;
   | stats count AS CountB BY FieldB
   ]
| eval Field=coalesce(fieldA,FieldB)
| table Field CountA CountB&lt;/LI-CODE&gt;&lt;P&gt;This solution has only the limit of 50,000 results for the subsearch, but I suppose that it isn't a problem.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 06:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613554#M50326</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-09-19T06:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Table- stats within stats</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613566#M50327</link>
      <description>&lt;P&gt;Firstly, your search is... strange. You do "table | fields | fields" with the same set of fields. That makes no sense.&lt;/P&gt;&lt;P&gt;Just using "| table" is enough.&lt;/P&gt;&lt;P&gt;I don't quite understand what you want to achieve though. Your "| stats count by FieldA, FieldB" will give you counts by each combination of FieldA and FieldB values. So now you only need to sum by value of one field or another if you want to get aggregated results.&lt;/P&gt;&lt;P&gt;Oh, and you don't need to do "| table" if you want to do "| stats" just after.&lt;/P&gt;&lt;P&gt;So just do "| stats count by FieldA FieldB" and summarize if needed&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 08:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613566#M50327</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-09-19T08:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Table- stats within stats</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613636#M50330</link>
      <description>&lt;P&gt;Thanks! I had some issues with the coalesce- was only CountA values. Tried doing this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=* sourcetype=_JSON logstreamName="*" OR logstreamName="*"&amp;nbsp; &amp;nbsp;|stats count as total by FieldA | appendcols [ search index=* sourcetype=_JSON logstreamName="*" OR logstreamName="*" | stats count(eval(FieldB&amp;gt; 0)) AS total by FieldA]&lt;/P&gt;&lt;P&gt;So I only want to interrogate the stats count of FieldA against values of FieldB that are greater than 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 15:52:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-would-I-create-a-Table-using-stats-within-stats/m-p/613636#M50330</guid>
      <dc:creator>Mena</dc:creator>
      <dc:date>2022-09-19T15:52:04Z</dc:date>
    </item>
  </channel>
</rss>

