How to modify and format numbers
AnsweredI've got bytes data summed correctly using "sum(obytes) as outboundbytes by _timeslice, application" as part of my query; however, I'd like to display the amount in Megabytes with 2 decimal places rather than something like 11,046,002 bytes. How do I modify the outboundbytes sum to show it as 11.05 MB
-
Official comment
Hi Steve,
The following query should work and should get you the result your looking for.
| sum(obytes) as outboundbytes by \_timeslice, application | outboundbytes/1024/1024 as outboundMB | format("%.2f MB",outboundMB) as outboundMB | fields - outboundbytes
We use the "format" operator to drop the extra decimals from the MB value, created from the conversion of bytes to MB, and also use this to add some text (MB) to the returned value. More help on the Format operator can be found via the following link.
https://help.sumologic.com/Search/Search-Query-Language/Search-Operators/format
This query should result in a formatted field value like "11.05 MB"
Comment actions
Please sign in to leave a comment.
Comments
1 comment