<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic i want to show two decimals after integer without changing values and if we give integer(52) also then output like 52.00 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306346#M165603</link>
    <description>&lt;P&gt;HI,&lt;/P&gt;

&lt;P&gt;a=0.54689556898&lt;BR /&gt;
b=1.25698&lt;BR /&gt;
c=0.5&lt;BR /&gt;
d=51&lt;/P&gt;

&lt;P&gt;I want output like&lt;/P&gt;

&lt;P&gt;a=0.54&lt;BR /&gt;
b=1.25&lt;BR /&gt;
c=0.50&lt;BR /&gt;
d=51.00&lt;/P&gt;

&lt;P&gt;Please do needful, how to write query&lt;/P&gt;

&lt;P&gt;i tried with this query but i am not getting&lt;BR /&gt;
| makeresults |eval Total=0.8 |  rex Field=Total "(?.&lt;EM&gt;).(?.&lt;/EM&gt;)" |eval EMP2=substr(FieldC,0,len(FieldC)-1)  | eval Result= FieldB.".".EMP2  |eval Result1=round(Result,3) | eval EMP5=substr(Result1,0,len(Result1)-1) | fields - FieldC, EMP2, FieldB, Result, Result1, _time&lt;/P&gt;</description>
    <pubDate>Fri, 13 Oct 2017 10:09:45 GMT</pubDate>
    <dc:creator>venu08673</dc:creator>
    <dc:date>2017-10-13T10:09:45Z</dc:date>
    <item>
      <title>i want to show two decimals after integer without changing values and if we give integer(52) also then output like 52.00</title>
      <link>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306346#M165603</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;

&lt;P&gt;a=0.54689556898&lt;BR /&gt;
b=1.25698&lt;BR /&gt;
c=0.5&lt;BR /&gt;
d=51&lt;/P&gt;

&lt;P&gt;I want output like&lt;/P&gt;

&lt;P&gt;a=0.54&lt;BR /&gt;
b=1.25&lt;BR /&gt;
c=0.50&lt;BR /&gt;
d=51.00&lt;/P&gt;

&lt;P&gt;Please do needful, how to write query&lt;/P&gt;

&lt;P&gt;i tried with this query but i am not getting&lt;BR /&gt;
| makeresults |eval Total=0.8 |  rex Field=Total "(?.&lt;EM&gt;).(?.&lt;/EM&gt;)" |eval EMP2=substr(FieldC,0,len(FieldC)-1)  | eval Result= FieldB.".".EMP2  |eval Result1=round(Result,3) | eval EMP5=substr(Result1,0,len(Result1)-1) | fields - FieldC, EMP2, FieldB, Result, Result1, _time&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 10:09:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306346#M165603</guid>
      <dc:creator>venu08673</dc:creator>
      <dc:date>2017-10-13T10:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: i want to show two decimals after integer without changing values and if we give integer(52) also then output like 52.00</title>
      <link>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306347#M165604</link>
      <description>&lt;P&gt;EDIT: Rounding MIGHT do what you want, if it will work for you it's easier and faster.  IF not, SCROLL DOWN there's a way to do this with truncation too.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Rounding&lt;/STRONG&gt; a single-precision number to two decimal places actually adds digits, so 0.5 rounds to 0.50.  Here's your 4 numbers in a run-anywhere to show that...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval nums=split("0.54689556898 1.25698 0.5 51", " ")
| mvexpand nums 
| eval num_2 = round(nums,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My results are &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;num_2   nums
51.00   51
1.26    1.25698
0.55    0.54689556898
0.50    0.5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Truncation:&lt;/STRONG&gt; If instead you really need truncation, combine the above technique with a rex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval nums=split("0.54689556898 1.25698 0.5 51", " ")
| mvexpand nums 
| eval num_2 = round(nums,3)
| rex field=num_2 "(?&amp;lt;num&amp;gt;\d+\.\d{2})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I do there is round to one extra digit (0.546) - now we have a known number of digits, so the rex just pulls out the integer part, then the first two decimals.&lt;/P&gt;

&lt;P&gt;That truncates like I think you might want!&lt;/P&gt;

&lt;P&gt;Happy Splunking!  Let me know if this works for you!&lt;/P&gt;

&lt;P&gt;-Rich&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 11:40:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306347#M165604</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2017-10-13T11:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: i want to show two decimals after integer without changing values and if we give integer(52) also then output like 52.00</title>
      <link>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306348#M165605</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
did you tried with round function?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval your_field=round(your_field,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 11:43:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306348#M165605</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-13T11:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: i want to show two decimals after integer without changing values and if we give integer(52) also then output like 52.00</title>
      <link>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306349#M165606</link>
      <description>&lt;P&gt;Finally i got output.&lt;/P&gt;

&lt;P&gt;Thank you Very much bro&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 12:37:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306349#M165606</guid>
      <dc:creator>venu08673</dc:creator>
      <dc:date>2017-10-13T12:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: i want to show two decimals after integer without changing values and if we give integer(52) also then output like 52.00</title>
      <link>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306350#M165607</link>
      <description>&lt;P&gt;If your problem is resolved, please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 12:49:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/i-want-to-show-two-decimals-after-integer-without-changing/m-p/306350#M165607</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-10-13T12:49:19Z</dc:date>
    </item>
  </channel>
</rss>

