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 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...