<?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 Multiple Stats Amounts using a Lookup Table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142761#M39657</link>
    <description>&lt;P&gt;HI, &lt;/P&gt;

&lt;P&gt;Can't seem to get this working. This is what I want, so I can do a multi stacked bar chart.&lt;BR /&gt;
Columns:&lt;BR /&gt;
Place, SubTotal 1, SubTotal 2, SubTotal 3, Grand Total.&lt;/P&gt;

&lt;P&gt;My lookup table will have 3 rows for each place.&lt;BR /&gt;&lt;BR /&gt;
Place, SubPlace 1&lt;BR /&gt;
Place, SubPlace 2&lt;BR /&gt;
Place SubPlace 3&lt;/P&gt;

&lt;P&gt;I have a search where I find sales amount by each SubPlace:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch|  lookup sales_lookup SalesID as SalesID OUTPUT Place, SalesType | stats sum(SalesRevenue) as SalesTypeTotal by SalesType 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't figure out how to have it all on one row so I have : Place, SubTotal 1, SubTotal 2, SubTotal 3, Grand Total.&lt;/P&gt;

&lt;P&gt;Any ideas? This should be easy ...&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2015 19:03:10 GMT</pubDate>
    <dc:creator>chrisboy68</dc:creator>
    <dc:date>2015-06-04T19:03:10Z</dc:date>
    <item>
      <title>Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142761#M39657</link>
      <description>&lt;P&gt;HI, &lt;/P&gt;

&lt;P&gt;Can't seem to get this working. This is what I want, so I can do a multi stacked bar chart.&lt;BR /&gt;
Columns:&lt;BR /&gt;
Place, SubTotal 1, SubTotal 2, SubTotal 3, Grand Total.&lt;/P&gt;

&lt;P&gt;My lookup table will have 3 rows for each place.&lt;BR /&gt;&lt;BR /&gt;
Place, SubPlace 1&lt;BR /&gt;
Place, SubPlace 2&lt;BR /&gt;
Place SubPlace 3&lt;/P&gt;

&lt;P&gt;I have a search where I find sales amount by each SubPlace:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch|  lookup sales_lookup SalesID as SalesID OUTPUT Place, SalesType | stats sum(SalesRevenue) as SalesTypeTotal by SalesType 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't figure out how to have it all on one row so I have : Place, SubTotal 1, SubTotal 2, SubTotal 3, Grand Total.&lt;/P&gt;

&lt;P&gt;Any ideas? This should be easy ...&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 19:03:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142761#M39657</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2015-06-04T19:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142762#M39658</link>
      <description>&lt;P&gt;If I'm understanding your question correctly, I believe something like this should work:&lt;BR /&gt;
| eval GrandTotal = SubTotal1+SubTotal2+SubTotal3&lt;BR /&gt;
| table Place SubTotal1 SubTotal2 SubTotal3 GrandTotal&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 19:19:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142762#M39658</guid>
      <dc:creator>hogan24</dc:creator>
      <dc:date>2015-06-04T19:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142763#M39659</link>
      <description>&lt;P&gt;Hmm, but I can't figure out how to do that in a search query. &lt;/P&gt;

&lt;P&gt;For example, considering I have 3 sales types for each Place named, subTotal1, SubTotal2 and SubTotal3, executing this query will return&lt;/P&gt;

&lt;P&gt;mysearch |  lookup salesID_lookup SalesID as SalesID OUTPUT Place, SalesType | stats sum(SalesRevenue) as SalesTypeTotal by SalesType&lt;/P&gt;

&lt;P&gt;SubTotal1 1000&lt;BR /&gt;
SubTotal2 1200&lt;BR /&gt;
SubTotal2 1100&lt;/P&gt;

&lt;P&gt;What I want is:&lt;/P&gt;

&lt;P&gt;Place, SubTotal1, SubTotal2, SubTotal3, Grand Total.&lt;/P&gt;

&lt;P&gt;Where Grand Total is the total of all the SubTotals for each Place.  Hope I'm explaining it correctly.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 19:45:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142763#M39659</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2015-06-04T19:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142764#M39660</link>
      <description>&lt;P&gt;Ahh, I think I see what you're saying. You're getting multiple rows and you want to have 1 row with multiple columns, is that correct? If so, try piping the results to 'transpose' (| tranpose) and see if that puts you in the right direction. &lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 19:49:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142764#M39660</guid>
      <dc:creator>hogan24</dc:creator>
      <dc:date>2015-06-04T19:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142765#M39661</link>
      <description>&lt;P&gt;Here's another way that I think may be more what you're looking for:&lt;BR /&gt;
| eval SubTotal1  = if(columnName=="SubTotal1", countColumnName, null)&lt;BR /&gt;
| eval SubTotal2  = if(columnName=="SubTotal2", countColumnName, null)&lt;BR /&gt;
| eval SubTotal3  = if(columnName=="SubTotal3", countColumnName, null)&lt;BR /&gt;
| table SubTotal1 SubTotal2 SubTotal3&lt;BR /&gt;
| stats sum(SubTotal1) as SubTotal1 sum(SubTotal2) as SubTotal2 sum(SubTotal3) as SubTotal3&lt;BR /&gt;
| eval GrandTotal = SubTotal1+SubTotal2+SubTotal3&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 19:57:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142765#M39661</guid>
      <dc:creator>hogan24</dc:creator>
      <dc:date>2015-06-04T19:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142766#M39662</link>
      <description>&lt;P&gt;Building off of your comment to @hogan24 above, you currently have: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | lookup salesID_lookup SalesID as SalesID OUTPUT Place, SalesType | stats sum(SalesRevenue) as SalesTypeTotal by SalesType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But you want the sum of each sales type over place grouped by SalesType, so instead of stats, lets start with trying  &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/chart"&gt;chart&lt;/A&gt; which can do exactly that. (aside: As needs change there are more esoteric ways of building such a table here such using stats followed by &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/xyseries"&gt;xyseries&lt;/A&gt; which lets you do some interesting manipulations in between the two commands but that will be down the line when the basic chart command stops fitting your use case)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | lookup salesID_lookup SalesID as SalesID OUTPUT Place, SalesType | chart sum(SalesRevenue) over Place by SalesType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you a result table like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Place          Type1  Type2  Type3
 Somewhere      123    456    789
 SomewhereElse  111    222    333
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now if you're wanting totals for each place, assuming the places are non-numeric that's as easy as then piping to &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Addtotals"&gt;addtotals&lt;/A&gt; and playing with the options you want for example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | lookup salesID_lookup SalesID as SalesID OUTPUT Place, SalesType | chart sum(SalesRevenue) over Place by SalesType | addtotals col=true labelfield=Place
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Assuming we're building on the data from the last step this should now look like: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Place          Type1  Type2  Type3 Total
 Somewhere      123    456     789  1368
 SomewhereElse  111    222     333   666
 Total          234    678    1122  2034
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2015 20:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142766#M39662</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-06-04T20:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142767#M39663</link>
      <description>&lt;P&gt;This didn't work. it made it close, but did not group the Place. For the same place, it duplicated a row for each SubTotal. &lt;/P&gt;

&lt;P&gt;This is what I'm looking for on one row:&lt;BR /&gt;
Place, SubTotal1, SubTotal2, SubTotal3, Grand Total.&lt;/P&gt;

&lt;P&gt;Thanks for your help.&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 20:18:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142767#M39663</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2015-06-04T20:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Amounts using a Lookup Table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142768#M39664</link>
      <description>&lt;P&gt;Ah , that was it, I needed "chart", not "stats"&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 20:29:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Amounts-using-a-Lookup-Table/m-p/142768#M39664</guid>
      <dc:creator>chrisboy68</dc:creator>
      <dc:date>2015-06-04T20:29:50Z</dc:date>
    </item>
  </channel>
</rss>

