Splunk Search

Format Result set Numbers

lpolo
Motivator

I have the following result set:

_time                       Visits
Sunday, November 27, 2011   667044
Saturday, November 26, 2011 659234
Sunday, November 20, 2011   648686
Saturday, October 29, 2011  640808

Is there a way to format the Visits' number as follow?

_time                       Visits
Sunday, November 27, 2011   667,044
Saturday, November 26, 2011 659,234
Sunday, November 20, 2011   648,686
Saturday, October 29, 2011  640,808

Regards,
Lp

Tags (1)
1 Solution

tgow
Splunk Employee
Splunk Employee

You can use the fieldformat command to accomplish this.

Try this in search:

| fieldformat Visits = tostring(Visits, "commas") | table _time, Visits

Here is a link to more information:

http://docs.splunk.com/Documentation/Splunk/4.2.4/SearchReference/Fieldformat

View solution in original post

tgow
Splunk Employee
Splunk Employee

You can use the fieldformat command to accomplish this.

Try this in search:

| fieldformat Visits = tostring(Visits, "commas") | table _time, Visits

Here is a link to more information:

http://docs.splunk.com/Documentation/Splunk/4.2.4/SearchReference/Fieldformat

lpolo
Motivator

It worked great.

Thanks.
Lp

0 Karma

banchio
Engager

Hi everybody!
This solution is great, but if you change column values to string you'll lose the ability to automatically calculate column totals: such totals will be wrong since they'll ignore every value containing commas.
Is there a way to apply this formatting without invalidating "|addcoltotals" functionalities?

Thank you very much in advance,
Matteo

-- EDIT --
SOLUTION is to pospone | eval tostring(...,"commas") to |addcoltotals: then everything is working fine!

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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