Splunk Search

tonumber command returns a null value

rphillips_splk
Splunk Employee
Splunk Employee

why does the tonumber command return a null value when the string being evaluated contains a space?

example:
string padded by a space character before the 1 returns null:
| stats count| eval test=" 1"|eval me=tonumber(test)

removing the padding returns a value:
| stats count| eval test="1"|eval me=tonumber(test)

workaround for strings with spaces:
| stats count| eval test=" 1"|eval me=trim(test)

Tags (4)
1 Solution

rphillips_splk
Splunk Employee
Splunk Employee

This has been identified as a bug and is targeted to be fixed in the 6.2.5 maintenance release (~Sept/Oct 2015)

View solution in original post

rphillips_splk
Splunk Employee
Splunk Employee

This has been identified as a bug and is targeted to be fixed in the 6.2.5 maintenance release (~Sept/Oct 2015)

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...