Splunk Search

Hi, Can i use sum and list command in single query

deepa_purushoth
Engager

For example,
Category | CategoryGroup |Price
AAA|Apple |80
AAA|Apple |90
BBB|Banana|40
BBB|Butterfruit|90

I want to display my data as
Category|CategoryGroup|Total
AAA|Apple|170
BBB|Banana|40
|Butterfuit|90

Please advice.
I tried i can able to get the category and categorygroup in list however i cant do sum, but i can show as count.

Tags (1)
0 Karma
1 Solution

elliotproebstel
Champion

Yes, you can simply add the stats list() after the sum:

your search| stats sum(Price) AS Total BY Category,CategoryGroup | stats list(CategoryGroup) AS CategoryGroup list(Total) AS Total BY Category

View solution in original post

elliotproebstel
Champion

Yes, you can simply add the stats list() after the sum:

your search| stats sum(Price) AS Total BY Category,CategoryGroup | stats list(CategoryGroup) AS CategoryGroup list(Total) AS Total BY Category

elliotproebstel
Champion

Hi @deepa_purushothaman - thanks for the upvote! If this solution works for you, will you accept it, so that other users can find it if they have the same question?

0 Karma

deepa_purushoth
Engager

Thank you elliotproebstel, this is helpful.

0 Karma

elliotproebstel
Champion

Glad to help!

0 Karma

deepa_purushoth
Engager

Thank you, but this yields me duplicate value in Category. I want to include list command as well to eliminate show as multiple record under each category.

0 Karma

HiroshiSatoh
Champion

Try this!

(your search)|stats sum(Price) as Total by Category,CategoryGroup
0 Karma
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!

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 ...

Index This | How many sevens are there between 1 and 100?

August 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...