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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...