<?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 Rounding errors in DQL query in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Rounding-errors-in-DQL-query/m-p/289356#M2750</link>
    <description>&lt;P&gt;I am trying to configure a Dashboard tile using DQL. I am able to pull the required data and run various calculations, however for the final stage I am trying to calculate an error rate, using total errors vs total numbers of calls&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can see the calculation is correct, however the output I am seeing is incorrect, due to rounding errors. An example I have is evidenced below, where I am hardcoding a value of 289, but when I divide this my 100 I see an output which is rounded down to the nearest integer (but with 2 decimal places visible)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rachel6842135_0-1762870545378.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30878i277FB67A28EC2BD6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rachel6842135_0-1762870545378.png" alt="rachel6842135_0-1762870545378.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rachel6842135_1-1762870369527.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30877i7D3CE9F817234699/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rachel6842135_1-1762870369527.png" alt="rachel6842135_1-1762870369527.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a setting I am missing which is somehow converting my number to an Integer before re-adding decimal places? I haven't been able to find anything - both fields are configured to show 2 decimal places in settings&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 17 Nov 2025 10:36:32 GMT</pubDate>
    <dc:creator>rachel6842135</dc:creator>
    <dc:date>2025-11-17T10:36:32Z</dc:date>
    <item>
      <title>Rounding errors in DQL query</title>
      <link>https://community.dynatrace.com/t5/DQL/Rounding-errors-in-DQL-query/m-p/289356#M2750</link>
      <description>&lt;P&gt;I am trying to configure a Dashboard tile using DQL. I am able to pull the required data and run various calculations, however for the final stage I am trying to calculate an error rate, using total errors vs total numbers of calls&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can see the calculation is correct, however the output I am seeing is incorrect, due to rounding errors. An example I have is evidenced below, where I am hardcoding a value of 289, but when I divide this my 100 I see an output which is rounded down to the nearest integer (but with 2 decimal places visible)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rachel6842135_0-1762870545378.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30878i277FB67A28EC2BD6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rachel6842135_0-1762870545378.png" alt="rachel6842135_0-1762870545378.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rachel6842135_1-1762870369527.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30877i7D3CE9F817234699/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rachel6842135_1-1762870369527.png" alt="rachel6842135_1-1762870369527.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a setting I am missing which is somehow converting my number to an Integer before re-adding decimal places? I haven't been able to find anything - both fields are configured to show 2 decimal places in settings&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2025 10:36:32 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Rounding-errors-in-DQL-query/m-p/289356#M2750</guid>
      <dc:creator>rachel6842135</dc:creator>
      <dc:date>2025-11-17T10:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding errors in DQL query</title>
      <link>https://community.dynatrace.com/t5/DQL/Rounding-errors-in-DQL-query/m-p/289360#M2751</link>
      <description>&lt;P&gt;Hi.&lt;BR /&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/97644"&gt;@rachel6842135&lt;/a&gt;Could you paste your DQL?&lt;BR /&gt;It's hard to come up with/verify something if you don't know the syntax&lt;BR /&gt;It’s integer division. In DQL, if both operands are integers (e.g., 289 / 100 or count()/count()), the result is truncated to an integer first and only then formatted — so you see 2.00&lt;BR /&gt;But try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd errorRate2 = 289.0
| fieldsAdd errorRate3 = errorRate2 / 100.0 
| fieldsReplace errorRate3 = round(errorRate3, 2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Or&amp;nbsp;For a real error-rate calc (total errors vs total calls), make one side a double:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| summarize total_calls = count(), total_errors = sum(is_error)
| fieldsAdd error_rate =
    if(total_calls == 0, 0.0,
       100.0 * toDouble(total_errors) / toDouble(total_calls))
| fieldsReplace error_rate = round(error_rate, 2)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 11 Nov 2025 14:32:32 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Rounding-errors-in-DQL-query/m-p/289360#M2751</guid>
      <dc:creator>t_pawlak</dc:creator>
      <dc:date>2025-11-11T14:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding errors in DQL query</title>
      <link>https://community.dynatrace.com/t5/DQL/Rounding-errors-in-DQL-query/m-p/289365#M2752</link>
      <description>&lt;P&gt;Thanks so much&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/42367"&gt;@t_pawlak&lt;/a&gt;&amp;nbsp;- your second solution (converting to double before calculating) has worked perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2025 15:11:18 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Rounding-errors-in-DQL-query/m-p/289365#M2752</guid>
      <dc:creator>rachel6842135</dc:creator>
      <dc:date>2025-11-11T15:11:18Z</dc:date>
    </item>
  </channel>
</rss>

