<?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 Using a first query on second query data in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Using-a-first-query-on-second-query-data/m-p/293305#M3055</link>
    <description>&lt;P&gt;Hello people.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; i have big issue, im playing with spans, and y need obtains a metric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my query&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch spans
| filter isNotNull( http.request.header.host)
//| fields endpoint.name, http.request.header.host, http.request.method, trace.id
and endpoint.name == "/api/inicio/v1/empresa/estadisticasV2" 
| fieldsAdd http.response.status_code, response_time = end_time - start_time
| summarize percentile(response_time, 90), promedio = avg(response_time), maximo = max(response_time), count(),  by:{endpoint.name}

| append 
  [ fetch spans 
   | filter isNotNull( http.request.header.host) and endpoint.name == "/api/inicio/v1/empresa/estadisticasV2" 
   | fieldsAdd http.response.status_code, response_time = end_time - start_time
   | summarize countIf(response_time &amp;gt;= promedio), countIf(response_time &amp;gt;= maximo) ,by:{endpoint.name} 
  ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want get the record count over promedio and count the max.&lt;/P&gt;&lt;P&gt;but my result was&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="Ellery_0-1768850744722.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/31667i75D4939FFEBA8811/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ellery_0-1768850744722.png" alt="Ellery_0-1768850744722.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jan 2026 21:27:54 GMT</pubDate>
    <dc:creator>Ellery</dc:creator>
    <dc:date>2026-01-19T21:27:54Z</dc:date>
    <item>
      <title>Using a first query on second query data</title>
      <link>https://community.dynatrace.com/t5/DQL/Using-a-first-query-on-second-query-data/m-p/293305#M3055</link>
      <description>&lt;P&gt;Hello people.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; i have big issue, im playing with spans, and y need obtains a metric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my query&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch spans
| filter isNotNull( http.request.header.host)
//| fields endpoint.name, http.request.header.host, http.request.method, trace.id
and endpoint.name == "/api/inicio/v1/empresa/estadisticasV2" 
| fieldsAdd http.response.status_code, response_time = end_time - start_time
| summarize percentile(response_time, 90), promedio = avg(response_time), maximo = max(response_time), count(),  by:{endpoint.name}

| append 
  [ fetch spans 
   | filter isNotNull( http.request.header.host) and endpoint.name == "/api/inicio/v1/empresa/estadisticasV2" 
   | fieldsAdd http.response.status_code, response_time = end_time - start_time
   | summarize countIf(response_time &amp;gt;= promedio), countIf(response_time &amp;gt;= maximo) ,by:{endpoint.name} 
  ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want get the record count over promedio and count the max.&lt;/P&gt;&lt;P&gt;but my result was&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="Ellery_0-1768850744722.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/31667i75D4939FFEBA8811/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ellery_0-1768850744722.png" alt="Ellery_0-1768850744722.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jan 2026 21:27:54 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Using-a-first-query-on-second-query-data/m-p/293305#M3055</guid>
      <dc:creator>Ellery</dc:creator>
      <dc:date>2026-01-19T21:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using a first query on second query data</title>
      <link>https://community.dynatrace.com/t5/DQL/Using-a-first-query-on-second-query-data/m-p/293311#M3056</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;first, i hope i understand your requirement / intended result correctly. A couple of observations upfront:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;you do not need to calculate the response time of a span manually, it is done by Dynatrace and available via the &lt;STRONG&gt;duration&lt;/STRONG&gt; field, see example.&lt;/LI&gt;
&lt;LI&gt;Your query can never show a number of spans with a response time larger than the maximum as you are using the same timeframe for both queries. So the only possibility is that there are spans with a duration equal to the max, but never larger as the max was already found by the first query. Please clarify and provide more detail on your use case.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Here is my interpretation &amp;amp; example:&lt;/P&gt;
&lt;P&gt;There is a certain reference of "performance" for certain requests. This reference can be defined by e.g. the observed response time during a certain timeframe (last business week in my case, or e.g. yesterday). Then, the current performance is compared to that reference and you want to see if your services are performing better or worse than before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus i compiled this example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fetch spans, from:@w1 //this business week, from Monday to now
| fields start_time, end_time, duration, endpoint.name
| filter endpoint.name == "/api/products"
| join [

        fetch spans, from:-1w@w1, to:@w5 //last business week
        | fields start_time, end_time, duration, endpoint.name
        | filter endpoint.name == "/api/products"
        | summarize promedio=avg(duration), maximo=max(duration), by:endpoint.name

], on:endpoint.name, prefix:"reference."
| summarize mas_que_promedio = countIf(duration &amp;gt;= reference.promedio), mas_que_maximo = countIf(duration &amp;gt;= reference.maximo)&lt;/LI-CODE&gt;
&lt;P&gt;you can copy paste this example and try it on our &lt;A href="https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.notebooks" target="_self"&gt;Playground environment&lt;/A&gt; based on real data.&lt;/P&gt;
&lt;P&gt;Ultimately in case you need to be alerted in case the response time of your requests exceeds your specified thresholds consider using &lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/platform/davis-ai/anomaly-detection/set-up-a-customized-anomaly-detector/how-to-set-up/anomaly-detection-app" target="_self"&gt;Dynatrace anomaly detection&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2026 08:21:29 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Using-a-first-query-on-second-query-data/m-p/293311#M3056</guid>
      <dc:creator>peter_zahrer</dc:creator>
      <dc:date>2026-01-20T08:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using a first query on second query data</title>
      <link>https://community.dynatrace.com/t5/DQL/Using-a-first-query-on-second-query-data/m-p/293321#M3058</link>
      <description>&lt;P&gt;Work's Thank's a lot !!!&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2026 12:08:42 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Using-a-first-query-on-second-query-data/m-p/293321#M3058</guid>
      <dc:creator>Ellery</dc:creator>
      <dc:date>2026-01-20T12:08:42Z</dc:date>
    </item>
  </channel>
</rss>

