Dashboards & Visualizations

How to format large number to display millions?

mihir_hardas
Explorer

I created a table visualization in dashboard studio. Search query has large numbers. How to format that number to display millions as 1.28M i.e with letter M 

Not a mini-program with eval please. Need a good function, format specifer

Labels (2)
Tags (2)
0 Karma

tfujita_splunk
Splunk Employee
Splunk Employee

Perhaps this could be a solution.

How to convert a large number to string with expressions of long and short scales, or neither.

https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-large-number-to-string-with-expressio...

 

Numeral system macros for Splunk

https://splunkbase.splunk.com/app/6595

 

mihir_hardas
Explorer

Example :

index=log-13120-nonprod-c laas_appId=qbmp.prediction-engine ("current predicted as" OR "predicted as Prediction")

| lookup freq_used_jobs_bmp_3months.csv jobname output jobname local=true
| stats count(predictionStatus) | fieldformat count=tostring(count,"commas")


This results into a large number of 163,071,022. 
If we have a good function for converting into million, billion dynamically as per the result. Also a format specifier if we want the result in million or billion.

Eg above can be 163.1 M or 0.1B like that.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There is no function that does what you describe.  Feel free to write one or suggest it at https://ideas.splunk.com.

You still haven't explained what you meant by "somehow this does not work" in response to my first answer.

---
If this reply helps you, Karma would be appreciated.
0 Karma

mihir_hardas
Explorer

If I get number as output, 163,282,548 then a function should be able to convert it to International units of millions, billions by a symbol = M. So the above should read as 163.3 M 

There should be arguments for number of digits for rounding etc 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There's no Dashboard Studio option or function that do what you ask.  Consider asking for it at https://ideas.splunk.com.

In the meantime, you can get the same effect with a little more SPL.  Use fieldformat to convert millions into a smaller number.  Use fieldformat instead of eval to preserve the original field value.

| fieldformat value = value / 1000000

Then set these visualization options (as well as any others you need):

"options": {
        "unit": "M",
        "numberPrecision": 3
    }

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

mihir_hardas
Explorer

Hi,

 

somehow this does not work ! 😞

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Tell us more, please.  What results do you get?  Can you share the XML for that part of the dashboard?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Deprecation of Splunk Observability Kubernetes “Classic Navigator” UI starting ...

Access to Splunk Observability Kubernetes “Classic Navigator” UI will no longer be available starting January ...

Now Available: Cisco Talos Threat Intelligence Integrations for Splunk Security Cloud ...

At .conf24, we shared that we were in the process of integrating Cisco Talos threat intelligence into Splunk ...