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!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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