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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...