Splunk Search

How to do arithmetic to stings that are converted to numbers?

sumarri
Path Finder

So I have the fields that I want to subtract.  One is SequenceNumber_Comment (ex 211) and SequenceNumber_Withdrawal (ex 210). I want to subtract the values and put them in the variable match. Below is the SPLI have but I get an empty value.

| eval match = tonumber(SequenceNumber_Comment) - tonumber(SequenceNumber_Withdrawal)

 

What do I do??? 

Thank you!!!

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Do your strings have spaces? Try using the trim function

| eval match = tonumber(trim(SequenceNumber_Comment)) - tonumber(trim(SequenceNumber_Withdrawal))

sumarri
Path Finder

It does not... I gave it shot, but thank you for the idea! 

0 Karma
Get Updates on the Splunk Community!

Meet Duke Cyberwalker | A hero’s journey with Splunk

We like to say, the lightsaber is to Luke as Splunk is to Duke. Curious yet? Then read Eric Fusilero’s latest ...

The Future of Splunk Search is Here - See What’s New!

We’re excited to introduce two powerful new search features, now generally available for Splunk Cloud Platform ...

Splunk is Nurturing Tomorrow’s Cybersecurity Leaders Today

Meet Carol Wright. She leads the Splunk Academic Alliance program at Splunk. The Splunk Academic Alliance ...