Dashboards & Visualizations

Find highest and lowest value from split by two fields

Justinboucher0
Path Finder

I'm using the Splunk sample tutorial data and I want to figure out how to find the best selling and worst selling product by a specific product_name and country. Here is my current search:

 

index="tutorial" sourcetype="access_combined_wcookie" "action=purchase" 
| iplocation clientip 
| eventstats count as units_sold by product_name Country

 

 However, if I just do a min and max in the next stats command I don't really get the associated product_name or I don't get the Country as well. My expected result is:

CountryBest Selling

Worst Selling

United StatesProduct1

Product6

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Would something like this work?

index="tutorial" sourcetype="access_combined_wcookie" "action=purchase" 
| iplocation clientip 
| stats count as units_sold by product_name Country
| sort Country units_sold
| stats first(product_name) as worse_selling last(product_name) as best_selling by Country

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Would something like this work?

index="tutorial" sourcetype="access_combined_wcookie" "action=purchase" 
| iplocation clientip 
| stats count as units_sold by product_name Country
| sort Country units_sold
| stats first(product_name) as worse_selling last(product_name) as best_selling by Country
0 Karma

Justinboucher0
Path Finder

I'm an idiot. I didn't even think about first and last. I got tunnel vision on the units_sold. TY

0 Karma
Get Updates on the Splunk Community!

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...

Cisco Use Cases, ITSI Best Practices, and More New Articles from Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Build Your First SPL2 App!

Watch the recording now!.Do you want to SPL™, too? SPL2, Splunk's next-generation data search and preparation ...