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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...