Comments

5 comments

  • Avatar
    Piotr Woch

    Hello Ran!

    Please check out this page on our documentation site: https://help.sumologic.com/05Search/Search-Query-Language/Search-Operators/format

    It talks about one of the ways you can achieve what you need using format() operator.

    Please let me know if you have any further questions.

    0
    Comment actions Permalink
  • Avatar
    Kevin Keech

    Hi Ran,

    The following should round your supplied number to 2 decimal places. Where <field> contains the number you want to round and <new_field> is the name you supply to the new field that contains your rounded value. 

     

    | format("%.2f", <field>) as <new_field>
    0
    Comment actions Permalink
  • Avatar
    Ran Styr

    Hi Kevin,

    Thanks for the answer.  I do see that the number is rounded but I am getting trailing zeros.
    For example 4.59000

    Is there a way to remove the zeros after the second decimal places?
    Thanks,
    Ran

    1
    Comment actions Permalink
  • Avatar
    Ran Styr

    I Found the issue. avg returns a number with more than 2  decimal places. 
    Is there a way to format avg (when using also groups)?


    | count(name),avg(value) group by name , lines
    0
    Comment actions Permalink
  • Avatar
    Rajesh Goel

    Moreover the aggregate functions cannot be plotted as graph if it is not a number. So please suggest a viable solution if I want to show only 2 decimals.

    I did the below but now it is not showing me it as graph:

    • | round(_avg, 1) as _avg
    • | format("%.1f", _avg) as _avg

    If I add the below (to the above):

    • | num(_avg) as _avg

    then it enables the graphing option (like chart) but it displays the trailing 3 zeros, which I do not want

    • 47.90000

    Any suggestion?

    0
    Comment actions Permalink

Please sign in to leave a comment.