Splunk Search

How to write a query to show the top performer (Single Value)?

ranjitbrhm1
Communicator

Hello All, I want to write something that shows a single value with the below data
Customer M 5 Units
Customer N 15 Units
Customer O 52 Units
Customer P 54 Units
Customer W 522 Units
Customer Q 51 Units

I want to see who is my biggest customer here. Obviously my biggest customer is W. But is there a way where i can show the biggest customer name on my dashboard? Like Biggest customer - "Customer W" I dont need to know any other details, Just the biggest customer name.
Thanks

Tags (2)
0 Karma
1 Solution

niketn
Legend

@ranjitbrhm1, you can sort Units in descending order and then retain only the first row. Then save the search with Single Value visualization on your dashboard. If you are on Splunk Enterprise 6.6. or higher and want to show top 5 Customers you can retain | head 5 and use Single Value with Trellis Layout to show all 5 customers.

<yourCurrentSearch>
| sort - Units
| head 1

Following is a run anywhere example based on your sample data:

| makeresults
| eval data="Customer=M,Units=5;Customer=N,Units=15;Customer=O,Units=52;Customer=P,Units=54;Customer=W,Units=522;Customer=Q,Units=51"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| KV
| table Customer Units
| sort - Units
| head 1

PS: You can also try out Status Indicator Custom Visualization for Similar output as Single Value.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@ranjitbrhm1, you can sort Units in descending order and then retain only the first row. Then save the search with Single Value visualization on your dashboard. If you are on Splunk Enterprise 6.6. or higher and want to show top 5 Customers you can retain | head 5 and use Single Value with Trellis Layout to show all 5 customers.

<yourCurrentSearch>
| sort - Units
| head 1

Following is a run anywhere example based on your sample data:

| makeresults
| eval data="Customer=M,Units=5;Customer=N,Units=15;Customer=O,Units=52;Customer=P,Units=54;Customer=W,Units=522;Customer=Q,Units=51"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| KV
| table Customer Units
| sort - Units
| head 1

PS: You can also try out Status Indicator Custom Visualization for Similar output as Single Value.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...