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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...