Splunk Search

Show all values 0 to 100 with precision up to 2 decimal points

barunbiswas
New Member

I am working on a single value dashboard panel where I am showing output in percentage with precision up to 2 decimal points (e.g. 60.25%). However, I want shows 0 and 100 as a whole number (NO decimal point precision for these two). Please advise whether it is possible.

0 Karma

cmerriman
Super Champion

i think this might work for you, you'll have to code it into the SPL, not the formatting.

...|eval interestingField=if(numerator/denominator*100=0 OR numerator/denominator*100=100, numerator/denominator*100, round(numerator/denominator*100,2))
0 Karma

Sukisen1981
Champion

Hi,

Try this, assuming X is your single value field :
| eval x=if(floor(x)=x,floor(x),x)
| where x!=0
| eval x=x." %"
| fields _time,x

Based and checked my solution on this excellent entry - https://answers.splunk.com/answers/443308/how-to-round-values-to-2-decimal-places-but-only-f.html
Checked for 0 and with decimal, the solution works.
Set your number format to 0.00 in the single value visualization

0 Karma

barunbiswas
New Member

Thanks for your reply. However, it is not working in the dashboard.

0 Karma

Sukisen1981
Champion

can you be more specific? what is no working? no values or the decimal?

0 Karma

barunbiswas
New Member

In dashboard, it is showing all values in 0.00 format. I think that single value visualization format is taking precedence over the spl?

0 Karma

Sukisen1981
Champion

if you dont save it in the dashboard and just run the search and see the visualization tab, is that working?

0 Karma

Sukisen1981
Champion

why not just round off the single value field to 0 decimal places?

0 Karma

barunbiswas
New Member

I think I should have been more clear with my question. I want to show all values except 0 & 100 with precision up to 2 decimal points (e.g. 60.25%); and I want to show 0 & 100 as a whole number. Any advice on this please.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...