Hello everybody,
I need to calculate the total sales value by product over month and calculate the percentage in relation to the total monthly sales value per product:
For exemple:
I have the Top 5 products sold in a month:
Product_Name Total_Sales
Product 1 $100
Product 2 $200
Product 3 $300
Product 4 $400
Product 5 $500
The Total_sold sold was 1500. Now I need to calculate the percentage that Total_Sales is in relation to Total Sold:
Product_Name Total_Sales Percentage
Product 1 $100 13%
Product 2 $200 19%
Product 3 $300 27%
Product 4 $400 33%
Product 5 $500 44%
I used this query to calculate the Total Sales:
sourcetype="vendor_sales"| chart sum(price) as price over product_name
Could you help me?
Thaks All.
sure! try this:
sourcetype="vendor_sales"|eventstats sum(price) as total_sales |stats sum(price) as sales max(total_sales) as total_sales by product_name|eval Percentage=sales/total_sales*100
if you're only looking for the top 10 products compared to total sales overall, add at the end:
|sort 0 - sales|head 10
if you want the percentage for the top 10 products and just the total sales for the top 10 products, try this:
sourcetype="vendor_sales" |stats sum(price) as sales by product_name|sort 0 - sales|head 10|eventstats sum(sales) as total_sales|eval Percentage=sales/total_sales*100
sure! try this:
sourcetype="vendor_sales"|eventstats sum(price) as total_sales |stats sum(price) as sales max(total_sales) as total_sales by product_name|eval Percentage=sales/total_sales*100
if you're only looking for the top 10 products compared to total sales overall, add at the end:
|sort 0 - sales|head 10
if you want the percentage for the top 10 products and just the total sales for the top 10 products, try this:
sourcetype="vendor_sales" |stats sum(price) as sales by product_name|sort 0 - sales|head 10|eventstats sum(sales) as total_sales|eval Percentage=sales/total_sales*100
Thank you man! Works great!