<?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 How to round a number when displaying results in a chart? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415895#M119714</link>
    <description>&lt;P&gt;I am trying to display the response times of services for the last 7 days in a chart , but I want to round the response time .&lt;BR /&gt;
for example I only want 2 digits to be displayed after decimal .&lt;/P&gt;

&lt;P&gt;My query :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart avg(response_time) over services by Date
| foreach * [eval response_time = round(response_time,2)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the above query doesn't work for me&lt;/P&gt;</description>
    <pubDate>Mon, 20 Aug 2018 14:28:59 GMT</pubDate>
    <dc:creator>navd</dc:creator>
    <dc:date>2018-08-20T14:28:59Z</dc:date>
    <item>
      <title>How to round a number when displaying results in a chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415895#M119714</link>
      <description>&lt;P&gt;I am trying to display the response times of services for the last 7 days in a chart , but I want to round the response time .&lt;BR /&gt;
for example I only want 2 digits to be displayed after decimal .&lt;/P&gt;

&lt;P&gt;My query :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart avg(response_time) over services by Date
| foreach * [eval response_time = round(response_time,2)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the above query doesn't work for me&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 14:28:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415895#M119714</guid>
      <dc:creator>navd</dc:creator>
      <dc:date>2018-08-20T14:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to round a number when displaying results in a chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415896#M119715</link>
      <description>&lt;P&gt;@navd while using foreach as a template you would need to use &lt;CODE&gt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;&lt;/CODE&gt; to replace template value for eval. Since you have used &lt;CODE&gt;chart&lt;/CODE&gt; ... &lt;CODE&gt;over services by Date&lt;/CODE&gt;. Your first column will be services and other Columns would be Date field. Following is what you can try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| chart avg(response_time) over services by Date
| rename * as avg_*
| rename avg_services as services 
| foreach avg_* [eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"= round('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',2)]
| rename avg_* as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search example based on Splunk's _internal index similar to your query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd
| chart avg(date_second) as date_second by component date_hour
| rename * as avg_*
| rename avg_component as component
| foreach avg* [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=round('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',2)]
| rename avg_* as *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Aug 2018 14:57:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415896#M119715</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-20T14:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to round a number when displaying results in a chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415897#M119716</link>
      <description>&lt;P&gt;This worked for me , but is there a way to sort the result in asc or desc order ?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 16:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415897#M119716</guid>
      <dc:creator>navd</dc:creator>
      <dc:date>2018-08-20T16:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to round a number when displaying results in a chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415898#M119717</link>
      <description>&lt;P&gt;@navd your Date field is String time so sorting would depend on what Date field looks like... for example&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;YYYY/MM/DD&lt;/CODE&gt; format date will get sorted correctly however &lt;CODE&gt;DD/MM/YYYY&lt;/CODE&gt; will not. So you might have to apply Serial number to your Date field before Chart and remove the same after Chart command.&lt;/P&gt;

&lt;P&gt;For us to assist you better, you will need to provide Date field sample values and also current output vs expected output result.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 16:49:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415898#M119717</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-20T16:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to round a number when displaying results in a chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415899#M119718</link>
      <description>&lt;P&gt;I am using this | eval Date=strftime(_time, "%Y-%m-%d") to display the Date as YYYY/MM/DD&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 18:11:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415899#M119718</guid>
      <dc:creator>navd</dc:creator>
      <dc:date>2018-08-20T18:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to round a number when displaying results in a chart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415900#M119719</link>
      <description>&lt;P&gt;@niketnilay  so with the above query my output looks something like below one . Now want to actually display these responsetime  values in asc or desc order , so how do I sort them &lt;/P&gt;

&lt;H2&gt;2018-09-07&lt;/H2&gt;

&lt;P&gt;165565&lt;BR /&gt;
125&lt;BR /&gt;
44664646.23&lt;BR /&gt;
1.1&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 13:56:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-round-a-number-when-displaying-results-in-a-chart/m-p/415900#M119719</guid>
      <dc:creator>navd</dc:creator>
      <dc:date>2018-09-07T13:56:57Z</dc:date>
    </item>
  </channel>
</rss>

