<?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 to calculate a value from 2 different sources? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501264#M140629</link>
    <description>&lt;P&gt;I am pretty new to splunk. It would be great if someone can help me with a search command. I have productId as one of fields in my index data. I added lookup from products.csv which has productId, product_name &amp;amp; price. Now I need a  bar chart with top 5 most selling products. How to get the total price from count and price? My current search is as below:&lt;/P&gt;

&lt;P&gt;index=* action="purchase" |lookup products productId as productId OUTPUT product_name price | top limit =5 product_name&lt;/P&gt;

&lt;P&gt;The above query gives me count of purchase transactions by productId. How to get the total sale amount for each product. something like:&lt;BR /&gt;
Product Name &amp;amp; Sale price (count by productId * price).&lt;BR /&gt;
Also how to make each bar a different color. The below is not helping:&lt;BR /&gt;
option name="charting.seriesColors"&amp;gt;[0x12BF05,0xEAD619,0xBF2105,0xD71F93,0xC294B1]&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:32:00 GMT</pubDate>
    <dc:creator>kirthi_d</dc:creator>
    <dc:date>2020-09-30T02:32:00Z</dc:date>
    <item>
      <title>How to calculate a value from 2 different sources?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501264#M140629</link>
      <description>&lt;P&gt;I am pretty new to splunk. It would be great if someone can help me with a search command. I have productId as one of fields in my index data. I added lookup from products.csv which has productId, product_name &amp;amp; price. Now I need a  bar chart with top 5 most selling products. How to get the total price from count and price? My current search is as below:&lt;/P&gt;

&lt;P&gt;index=* action="purchase" |lookup products productId as productId OUTPUT product_name price | top limit =5 product_name&lt;/P&gt;

&lt;P&gt;The above query gives me count of purchase transactions by productId. How to get the total sale amount for each product. something like:&lt;BR /&gt;
Product Name &amp;amp; Sale price (count by productId * price).&lt;BR /&gt;
Also how to make each bar a different color. The below is not helping:&lt;BR /&gt;
option name="charting.seriesColors"&amp;gt;[0x12BF05,0xEAD619,0xBF2105,0xD71F93,0xC294B1]&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:32:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501264#M140629</guid>
      <dc:creator>kirthi_d</dc:creator>
      <dc:date>2020-09-30T02:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a value from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501265#M140630</link>
      <description>&lt;P&gt;To get the total sale, first count the number of sales for each product then multiply that number by the price.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* action="purchase" |lookup products productId as productId OUTPUT product_name price 
| top limit =5 product_name
| stats count values(price) as price by product_name
| eval totalSale = count * price
| table product_name count price totalSale
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Oct 2019 23:41:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501265#M140630</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-10-12T23:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a value from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501266#M140631</link>
      <description>&lt;P&gt;Thanks. For some reason when I use top, it doesn't display price or totalSale. I removed top and replaced with sort and head 5. It is not the best way to do, but dont know why top is creating problem&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 02:50:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501266#M140631</guid>
      <dc:creator>kirthi_d</dc:creator>
      <dc:date>2019-10-13T02:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a value from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501267#M140632</link>
      <description>&lt;P&gt;&lt;CODE&gt;top&lt;/CODE&gt; is a transforming command, similar to &lt;CODE&gt;stats&lt;/CODE&gt;, meaning it only returns the fields explicitly named in the arguments.  Usually, when &lt;CODE&gt;top limit=5 foo&lt;/CODE&gt; is used, they really want &lt;CODE&gt;sort 5 foo&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 13:40:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501267#M140632</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-10-13T13:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a value from 2 different source</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501268#M140633</link>
      <description>&lt;P&gt;got it. I included the fields and looks perfect now. Thanks much..&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 21:19:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-value-from-2-different-sources/m-p/501268#M140633</guid>
      <dc:creator>kirthi_d</dc:creator>
      <dc:date>2019-10-13T21:19:55Z</dc:date>
    </item>
  </channel>
</rss>

