Splunk Search

Sort and Sum...a more elegant way?

JamesPineda
New Member

New to dbs and Splunk.

Querying against a CSV file of buy events. Want to return top 10 Users by purchase totals.

I ran:
source="file_name.csv" | sort by userid | stats sum(price) as BuyerTotals by userId |rename userId as User | sort -num(BuyerTotals) by User limit=10

A sanity check indicates my returned values are correct.

Can anyone suggest a more elegant way of scripting?

Cheers,
James

Tags (4)
0 Karma

mayurr98
Super Champion

Hey
Try this !

source="file_name.csv"  | stats sum(price) as BuyerTotals by userId |rename userId as User | sort limit=10 BuyerTotals desc

Let me know if this helps you!

0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...