Splunk Search

How to use sum() for the $ values?

kiran331
Builder

Hi I have a csv file with $6.00, $6.11,etc as values. How can user sum() for these values?

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

You would've to process the fields that contains values with dollar sign to remove $ so that Splunk can treat them as number and then you can apply sum aggregation. See this runanywhere sample search on one of the method to replace $ sign.

| gentimes start=-1 | eval field1="$6.00 $1.11" | table field1 | makemv field1 | mvexpand field1 | eval field2=replace(field1,"\$","") | stats sum(field2)

View solution in original post

0 Karma

somesoni2
Revered Legend

You would've to process the fields that contains values with dollar sign to remove $ so that Splunk can treat them as number and then you can apply sum aggregation. See this runanywhere sample search on one of the method to replace $ sign.

| gentimes start=-1 | eval field1="$6.00 $1.11" | table field1 | makemv field1 | mvexpand field1 | eval field2=replace(field1,"\$","") | stats sum(field2)
0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...