<?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: DQL - Count records bigger than in a array of records in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/DQL-Count-records-bigger-than-in-a-array-of-records/m-p/283128#M2409</link>
    <description>&lt;P&gt;To count array elements fulfilling specific conditions you can use this query as example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries rt=avg(dt.service.request.response_time)
| fieldsAdd v=arraySum(iCollectArray(if(rt[]&amp;gt;100000,1, else:0)))&lt;/LI-CODE&gt;&lt;P&gt;with iterative expressions you can perform array transformation, by applying formula to every element. This way we produce array of 0s or 1s (or nulls when array element is null). As a alst step we just need to sum array elements to have counts.&lt;/P&gt;&lt;P&gt;Example timeseries looks like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1754424059846.png" style="width: 812px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29392iF9B724C8920FAD47/image-dimensions/812x270?v=v2" width="812" height="270" role="button" title="krzysztof_hoja_0-1754424059846.png" alt="krzysztof_hoja_0-1754424059846.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and when I apply threshold of 100ms, I get this count:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_1-1754424105996.png" style="width: 814px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29393i4390FD7F62C81093/image-dimensions/814x180?v=v2" width="814" height="180" role="button" title="krzysztof_hoja_1-1754424105996.png" alt="krzysztof_hoja_1-1754424105996.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you have multi day timeseries and want to have result grouped by days, here how to achieve it:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries rt=avg(dt.service.request.response_time), timestamp=start()
| fieldsAdd d=record(rt=rt[], timestamp=timestamp[])
| expand d
| summarize v=countIf(d[rt]&amp;gt;90000), by: {timestamp=d[timestamp]@d}&lt;/LI-CODE&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="krzysztof_hoja_2-1754424671983.png" style="width: 799px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29394i1480B083B596F6DB/image-dimensions/799x824?v=v2" width="799" height="824" role="button" title="krzysztof_hoja_2-1754424671983.png" alt="krzysztof_hoja_2-1754424671983.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Aug 2025 20:11:34 GMT</pubDate>
    <dc:creator>krzysztof_hoja</dc:creator>
    <dc:date>2025-08-05T20:11:34Z</dc:date>
    <item>
      <title>DQL - Count records bigger than in a array of records</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-Count-records-bigger-than-in-a-array-of-records/m-p/282547#M2389</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Is there any way to count records in a array if the values are bigger than a number?&lt;BR /&gt;&lt;BR /&gt;The scenario is to get the records from a response time timeseries metric and check how many records are more than 1.5 seconds and return the count.&lt;BR /&gt;&lt;BR /&gt;The function &lt;STRONG&gt;CountIf&lt;/STRONG&gt; doesn't seems to work with arrays.&lt;/P&gt;
&lt;P&gt;Anyone see a workaround?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2025 09:13:28 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-Count-records-bigger-than-in-a-array-of-records/m-p/282547#M2389</guid>
      <dc:creator>m_zol</dc:creator>
      <dc:date>2025-07-30T09:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - Count records bigger than in a array of records</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-Count-records-bigger-than-in-a-array-of-records/m-p/282558#M2390</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I was able to, partially, get what I need using &lt;STRONG&gt;expand&lt;/STRONG&gt; command.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Total de requests Válidas Com Sucesso
timeseries { Total_Requests_Sucesso = sum(dt.service.request.count), start=start(), end=end()}, by: { endpoint.name }, interval: 1m,
filter: { matchesValue(entityAttr(dt.entity.service, "tags"), $Tags) AND
       ((http.response.status_code &amp;gt;= 200 AND http.response.status_code &amp;lt;= 299) OR http.response.status_code == 422)}

// Total de requests Válidas Com Erro
| join [timeseries {Total_Requests_Erros = sum(dt.service.request.count, default:0), start=start(), end=end()}, by: {endpoint.name}, interval: 1m,
filter: {matchesValue(entityAttr(dt.entity.service, "tags"), $Tags) AND
       ((http.response.status_code &amp;gt;= 500 AND http.response.status_code &amp;lt;= 599) OR http.response.status_code == 408)}
], on: {endpoint.name}, fields:{Total_Requests_Erros, endpoint.name}

| filter matchesPhrase(endpoint.name, "POST /open-banking/payments/v4/pix/payments")

//Cálculo da Disponibilidade Pontual
| fieldsAdd Disponibilidade_Pontual = Total_Requests_Sucesso[] / (Total_Requests_Erros[] + Total_Requests_Sucesso[]) * 100

// Quantidade de registros no array (Disponível + Indisponível)
| fieldsAdd QuantidadeRegistros = arraySize(arrayRemoveNulls(Disponibilidade_Pontual))

// remoção de campos não necessários
//| FieldsRemove Total_Requests_Sucesso, Total_Requests_Erros

// expando os valores em diferentes linhas
| expand Disponibilidade_Pontual
| filter Disponibilidade_Pontual &amp;lt; 95


| summarize {
    Total_Indisponivel = count(),
    Total_Registros = takeLast(QuantidadeRegistros)

}, by:{endpoint.name, timeframe, interval}

| fieldsAdd TotalDisponivel = Total_Registros - Total_Indisponivel
| fieldsAdd Disponibilidade_Diaria = toDouble(TotalDisponivel) / toDouble(Total_Registros) * 100
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="m_zol_0-1753835625743.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29265iB50ED454E48D1CFB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="m_zol_0-1753835625743.png" alt="m_zol_0-1753835625743.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But this DQL gets the right result for one day, now I need to break the data for each day.. not sure how yet.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2025 00:34:17 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-Count-records-bigger-than-in-a-array-of-records/m-p/282558#M2390</guid>
      <dc:creator>m_zol</dc:creator>
      <dc:date>2025-07-30T00:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - Count records bigger than in a array of records</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-Count-records-bigger-than-in-a-array-of-records/m-p/283128#M2409</link>
      <description>&lt;P&gt;To count array elements fulfilling specific conditions you can use this query as example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries rt=avg(dt.service.request.response_time)
| fieldsAdd v=arraySum(iCollectArray(if(rt[]&amp;gt;100000,1, else:0)))&lt;/LI-CODE&gt;&lt;P&gt;with iterative expressions you can perform array transformation, by applying formula to every element. This way we produce array of 0s or 1s (or nulls when array element is null). As a alst step we just need to sum array elements to have counts.&lt;/P&gt;&lt;P&gt;Example timeseries looks like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1754424059846.png" style="width: 812px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29392iF9B724C8920FAD47/image-dimensions/812x270?v=v2" width="812" height="270" role="button" title="krzysztof_hoja_0-1754424059846.png" alt="krzysztof_hoja_0-1754424059846.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and when I apply threshold of 100ms, I get this count:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_1-1754424105996.png" style="width: 814px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29393i4390FD7F62C81093/image-dimensions/814x180?v=v2" width="814" height="180" role="button" title="krzysztof_hoja_1-1754424105996.png" alt="krzysztof_hoja_1-1754424105996.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you have multi day timeseries and want to have result grouped by days, here how to achieve it:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries rt=avg(dt.service.request.response_time), timestamp=start()
| fieldsAdd d=record(rt=rt[], timestamp=timestamp[])
| expand d
| summarize v=countIf(d[rt]&amp;gt;90000), by: {timestamp=d[timestamp]@d}&lt;/LI-CODE&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="krzysztof_hoja_2-1754424671983.png" style="width: 799px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29394i1480B083B596F6DB/image-dimensions/799x824?v=v2" width="799" height="824" role="button" title="krzysztof_hoja_2-1754424671983.png" alt="krzysztof_hoja_2-1754424671983.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 20:11:34 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-Count-records-bigger-than-in-a-array-of-records/m-p/283128#M2409</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-08-05T20:11:34Z</dc:date>
    </item>
  </channel>
</rss>

