Splunk Search

tostring commas on a negative number

flora123
Path Finder

Hello ALL!

x=-241

eval final_x=tostring(x,"commas")

It shows [-,241], but it should be [-241].

How could I show the negative number correctly?

Thanks a lot. 😃

Tags (1)
1 Solution

bwooden
Splunk Employee
Splunk Employee

Interesting....It works as advertised when x=-1241 or x=-41 but not x=-241 or x=-111241.

I file this as a bug. In the mean time, you may use this temporary workaround:

eval final_x=replace(tostring(x, "commas"),"-,","-")

View solution in original post

bwooden
Splunk Employee
Splunk Employee

Interesting....It works as advertised when x=-1241 or x=-41 but not x=-241 or x=-111241.

I file this as a bug. In the mean time, you may use this temporary workaround:

eval final_x=replace(tostring(x, "commas"),"-,","-")

bwooden
Splunk Employee
Splunk Employee

Good news - This was reported and resolved last month in an upcoming release.

flora123
Path Finder

I found I think too much...replace is a good idea in this time.

Thanks again!

0 Karma

flora123
Path Finder

Oh... I get another trouble.
Because the x is a variable number... 😞
Anyway thank you very much.

0 Karma
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 ...