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!

.conf23 Registration is Now Open!

Time to toss the .conf-etti 🎉 —  .conf23 registration is open!   Join us in Las Vegas July 17-20 for ...

Don't wait! Accept the Mission Possible: Splunk Adoption Challenge Now and Win ...

Attention everyone! We have exciting news to share! We are recruiting new members for the Mission Possible: ...

Unify Your SecOps with Splunk Mission Control

In today’s post, I'm excited to share some recent Splunk Mission Control innovations. With Splunk Mission ...