<?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: creating table with different stats command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380205#M111293</link>
    <description>&lt;P&gt;You can probably use append/appendcols command to get results from your 4 searches into one search. Then you can format the output to get a single string with count value. Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Query1 | stats count as "Product Revenue" | appendcols 
[search Query2 | stats count as "Services Revenue"] | appendcols
[search Query3 | stats count as "Fixed Costs"] | appendcols
[search Query4 | stats count as Variable Costs] 
| eval temp=1 | untable temp Key Value
| eval FinalOutput=Key."=".Value 
| stats values(FinalOutput) as FinalOutput delim="," | nomv FinalOutput
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 May 2018 18:04:24 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-05-02T18:04:24Z</dc:date>
    <item>
      <title>creating table with different stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380202#M111290</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Is it possible to combile the stats from different queries in a single table or string. If I can create a string then table can be generated as:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
 | eval data="Product Revenue,420000;  Services Revenue,210000;  Fixed Costs,-170000; Variable Costs,-140000;"
 | makemv delim=";" data  | mvexpand data  | eval data=split(data,",")  | eval name=mvindex(data,0)  | eval value=mvindex(data,1)
 | table name value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to generate a Waterfall diagram with the results from different queries:-&lt;BR /&gt;
    Query1 | stats count as Product Revenue&lt;BR /&gt;
    Query2 | stats count as Services Revenue&lt;BR /&gt;
    Query3 | stats count as Fixed Costs&lt;BR /&gt;
    Query4 | stats count as Variable Costs&lt;/P&gt;

&lt;P&gt;However, I am not certain, how can I execute the 4 queries altogether and then combine the stats count as a string "Key1,Value1;Key2,Value2;Key3,Value3;Key4,Value4;"). &lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 16:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380202#M111290</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-05-02T16:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: creating table with different stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380203#M111291</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
  | eval data="Product Revenue,420000;  Services Revenue,210000;  Fixed Costs,-170000; Variable Costs,-140000;"
  | makemv delim=";" data  | mvexpand data  | eval data=split(data,",")  | eval name=mvindex(data,0)  | eval value=mvindex(data,1)
  | table name value
| eval temp=1 
| chart count over temp by name | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR (if it's not count but sum of value field)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
  | eval data="Product Revenue,420000;  Services Revenue,210000;  Fixed Costs,-170000; Variable Costs,-140000;"
  | makemv delim=";" data  | mvexpand data  | eval data=split(data,",")  | eval name=mvindex(data,0)  | eval value=mvindex(data,1)
  | table name value
| eval temp=1 
| chart sum(value) over temp by name | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 May 2018 16:28:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380203#M111291</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-02T16:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: creating table with different stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380204#M111292</link>
      <description>&lt;P&gt;Hi, Thanks for the reply. My question is for generating the string similar to data from 4 different queries. Here I put values in "data" only for example and my code is working fine. However, I really don't know, how can I execute 4 queries altogether, gather the stats count result and then create a single sting out of these 4 results and their name  (key-value pair). &lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 17:25:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380204#M111292</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-05-02T17:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: creating table with different stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380205#M111293</link>
      <description>&lt;P&gt;You can probably use append/appendcols command to get results from your 4 searches into one search. Then you can format the output to get a single string with count value. Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Query1 | stats count as "Product Revenue" | appendcols 
[search Query2 | stats count as "Services Revenue"] | appendcols
[search Query3 | stats count as "Fixed Costs"] | appendcols
[search Query4 | stats count as Variable Costs] 
| eval temp=1 | untable temp Key Value
| eval FinalOutput=Key."=".Value 
| stats values(FinalOutput) as FinalOutput delim="," | nomv FinalOutput
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 May 2018 18:04:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380205#M111293</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-02T18:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: creating table with different stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380206#M111294</link>
      <description>&lt;P&gt;Thanks a lot. I was trying to use the append command but appendcols is a better one. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 18:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/creating-table-with-different-stats-command/m-p/380206#M111294</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-05-02T18:06:36Z</dc:date>
    </item>
  </channel>
</rss>

