Splunk Search

How do I display 20% as an integer and still display as 20%

heamik
Engager

If I execute...

| stats avg(mem_free_percent) as mfp by Region
| fieldformat mfp=round(mfp, 1)."%"

It will display values like 20.5% However it breaks my radial dials I am assuming because the value gets converted to a string value. "fieldformat mfp=round(mfp, 1)" by itself still works in radial dials however 20.5% gets displayed as "20.5".

How do I add the % sign and still maintain the integer value?

Thanks

-Mike

Labels (2)
Tags (3)
0 Karma

rnowitzki
Builder

Hi @heamik,

with fieldformat you should be good. It's exactly made to keep the original type of data.

WIth this simple sample I could not reproduce your issue. After using fieldformat you can still calculate with mfp

|  makeresults 
| eval mfp=50.23
| fieldformat mfp=round(mfp, 1)."%"
| eval mfp=mfp+10.45

 

You could check what Splunk "thinks" the mfp is with | eval mfp_type = typeof(mfp)
Maybe something prior to the fieldformat already transforms it to a string?

You could try | eval mfp = tonumber(mfp) 

Hope it helps.
BR
Ralph


--
Karma and/or Solution tagging appreciated.
0 Karma
Get Updates on the Splunk Community!

Register to Attend BSides SPL 2022 - It's all Happening October 18!

Join like-minded individuals for technical sessions on everything Splunk!  This is a community-led and run ...

What's New in Splunk Cloud Platform 9.0.2208?!

Howdy!  We are happy to share the newest updates in Splunk Cloud Platform 9.0.2208! Analysts can benefit ...

Admin Console: A Single, Unified Interface for All Your Cloud Admin Needs

WATCH NOWJoin us to learn how the admin console can save you time and give you more control over the Splunk® ...