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.
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))
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
Thanks for your reply. However, it is not working in the dashboard.
can you be more specific? what is no working? no values or the decimal?
In dashboard, it is showing all values in 0.00 format. I think that single value visualization format is taking precedence over the spl?
if you dont save it in the dashboard and just run the search and see the visualization tab, is that working?
why not just round off the single value field to 0 decimal places?
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.