Splunk Search

Sum and table results from same field into 2 groups

davidoking
Explorer

Hi,

I have a few fields  and I am trying to get results on  e.g. Field1 (Person) Field2(Sales) Field3 (Location). 

what I am trying to do is somehow Sum(Sales) as Sales by Person (easy part), however I need to separate the location where sales came from e.g. Vic and Other State  and table the total result for each location per person. 

Person    Vic               Other 

Bob           $XX               $XX  

Mary         $xx                $XX

Phil            $XX              $XX

Thoughts? and thank you in advance

Labels (3)
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @davidoking,

This may happen is Location for Victoria is not exactly "Vic", if it is "Victoria" you should update if statement accordingly.

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

scelikok
SplunkTrust
SplunkTrust

Hi @davidoking,

You can use chart command like below to limit results for only one location;

| chart sum(Sales) as Sales over Person by Location limit=1 usenull=f

 If you want to Vic and others, you can use below;

| eval Location=if(Location!="Vic","Other",Location)
| chart sum(Sales) as Sales over Person by Location usenull=f
If this reply helps you an upvote and "Accept as Solution" is appreciated.

davidoking
Explorer

Thanks again, 

almost I almost got it, for some reason it only has Person and Other as columns, results from Vic are not showing, I used the second option. 

Just to confirm "Other" is just any sales that's not from Victoria. so I need to display Vic Sales Vs Sales from everywhere else from each Person. 

0 Karma

davidoking
Explorer

Thanks, I will give that a try. Appreciate the response

0 Karma

davidoking
Explorer

Side note, I was hope it was as simple as If Location (Vic) then Sum(sales) else ... however I don't believe splunk handles IF THEN ELSE statements. 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...