<?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 Re: Grail code help in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287780#M2672</link>
    <description>&lt;P&gt;The issue is that you're trying to reference fields created within the same summarize command and that isn't possible. You will have to do something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;rate5xx = toDouble(countIf(http.response.status_code &amp;gt;= 500) / count() * 100)&lt;/LI-CODE&gt;&lt;P&gt;EDIT: I see that you found a solution.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Oct 2025 19:03:14 GMT</pubDate>
    <dc:creator>ZackE</dc:creator>
    <dc:date>2025-10-13T19:03:14Z</dc:date>
    <item>
      <title>Grail code help</title>
      <link>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287767#M2668</link>
      <description>&lt;P&gt;Here is my code related to area trying to get the percentage of 5xx. I seem to have all the data here but the simple math is not working out...Any help?&lt;/P&gt;
&lt;P&gt;| summarize { dur_msAvg=avg(duration), dur_msMax=max(duration), dur_msMin=min(duration), dur_medMin=median(duration),&lt;BR /&gt;failedRequests300 = countIf(http.response.status_code &amp;gt;= 300 and http.response.status_code &amp;lt; 400),&lt;BR /&gt;failedRequests400 = countIf(http.response.status_code &amp;gt;= 400 and http.response.status_code &amp;lt;500),&lt;BR /&gt;failedRequests500 = countIf(http.response.status_code &amp;gt;= 500),&lt;BR /&gt;successfulRequests = countIf(http.response.status_code == 200),&lt;BR /&gt;allRequests = count(),&lt;BR /&gt;rate5xx = countIf( toDouble((failedRequests500 / allRequests) * 100) &amp;lt;&amp;gt; 0) },&lt;BR /&gt;by:{service.entity.name, endpoint.name, appName}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="derija_0-1760368990140.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30516iF1D7467EDF20E313/image-size/medium?v=v2&amp;amp;px=400" role="button" title="derija_0-1760368990140.png" alt="derija_0-1760368990140.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-10-13_08-19-48.jpg" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30517i8AF36E82BB75FCD3/image-size/large?v=v2&amp;amp;px=999" role="button" title="2025-10-13_08-19-48.jpg" alt="2025-10-13_08-19-48.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 12:21:01 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287767#M2668</guid>
      <dc:creator>derija</dc:creator>
      <dc:date>2025-10-15T12:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Grail code help</title>
      <link>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287768#M2669</link>
      <description>&lt;P&gt;Perhaps (since it involves percentage) you could&amp;nbsp;&lt;SPAN&gt;calculate the percentage directly, like this?&lt;BR /&gt;&lt;BR /&gt;rate5xx = toDouble(failedRequests500) / toDouble(allRequests) * 100&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Remarks:&lt;BR /&gt;- toDouble() ensures you're doing floating-point division.&lt;BR /&gt;- I don't think you need to wrap the percentage calculation in countIf — that’s only for counting events that match a condition.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 16:23:12 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287768#M2669</guid>
      <dc:creator>fstekelenburg</dc:creator>
      <dc:date>2025-10-13T16:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Grail code help</title>
      <link>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287772#M2670</link>
      <description>&lt;P&gt;Thanks for the option when I just try straight math whether I use toDouble or not I get&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="derija_0-1760373595830.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30519i66B5591DE620898B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="derija_0-1760373595830.png" alt="derija_0-1760373595830.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 16:40:23 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287772#M2670</guid>
      <dc:creator>derija</dc:creator>
      <dc:date>2025-10-13T16:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Grail code help</title>
      <link>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287778#M2671</link>
      <description>&lt;P&gt;Here is the fix...I had to END the summarize, then include the field...subtle but I missed it..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;|summarize by:{service.entity.name, endpoint.name, appName},&lt;BR /&gt;{ dur_msAvg=avg(duration), dur_msMax=max(duration), dur_msMin=min(duration), dur_medMin=median(duration),&lt;BR /&gt;failedRequests300 = countIf(http.response.status_code &amp;gt;= 300 and http.response.status_code &amp;lt; 400),&lt;BR /&gt;failedRequests400 = countIf(http.response.status_code &amp;gt;= 400 and http.response.status_code &amp;lt;500),&lt;BR /&gt;failedRequests500 = countIf(http.response.status_code &amp;gt;= 500),&lt;BR /&gt;successfulRequests = countIf(http.response.status_code == 200),&lt;BR /&gt;allRequests = count()}&lt;BR /&gt;|fieldsAdd rate5xx = if(allRequests &amp;gt; 0, toDouble(failedRequests500) / toDouble(allRequests) * 100)&lt;BR /&gt;|fieldsAdd rate4xx = if(allRequests &amp;gt; 0, toDouble(failedRequests400) / toDouble(allRequests) * 100)&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 18:47:38 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287778#M2671</guid>
      <dc:creator>derija</dc:creator>
      <dc:date>2025-10-13T18:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Grail code help</title>
      <link>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287780#M2672</link>
      <description>&lt;P&gt;The issue is that you're trying to reference fields created within the same summarize command and that isn't possible. You will have to do something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;rate5xx = toDouble(countIf(http.response.status_code &amp;gt;= 500) / count() * 100)&lt;/LI-CODE&gt;&lt;P&gt;EDIT: I see that you found a solution.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 19:03:14 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Grail-code-help/m-p/287780#M2672</guid>
      <dc:creator>ZackE</dc:creator>
      <dc:date>2025-10-13T19:03:14Z</dc:date>
    </item>
  </channel>
</rss>

