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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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