<?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: Transform &amp;quot;There are no records&amp;quot; into 0 with DQL in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Transform-quot-There-are-no-records-quot-into-0-with-DQL/m-p/268214#M1634</link>
    <description>&lt;P&gt;&lt;SPAN&gt;"There are no records" message appears instead of chart in 2 cases:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Where result set is empty / no records returned &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;All timeseries to display contain only nulls / no values&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;To avoid this we need to make sure that there is always a result and it contains data. Null is valid value of timeseries which means no data, but it this it may be caused as a result of division of 0 by 0&lt;/P&gt;&lt;P&gt;Additionally there is another problem with join in this query: left query (&lt;EM&gt;&lt;STRONG&gt;timeseries&lt;/STRONG&gt;&lt;/EM&gt; with "failed == true" condition) will not return a timeseries for a specific service when there is no failed requests and this cause that a service will not be present in the final data at all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final query can look like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries total = sum(dt.service.request.count, default:0), nonempty:true,  by: { dt.entity.service }
, filter: { ( in(dt.entity.service, classicEntitySelector("type(service),tag(\"Kubernetes_ClusterName:payments\")")))  }
| fieldsAdd key=record(dt.entity.service)

| join [ 
  timeseries failed = sum(dt.service.request.count, default:0), nonempty:true, by: { dt.entity.service } 
  , filter: { failed == true and ( in(dt.entity.service, classicEntitySelector("type(service),tag(\"Kubernetes_ClusterName:payments\")"))) }
  | fieldsAdd key=record(dt.entity.service)

], on: { key }, fields: { failed }, kind:leftOuter

| fieldsAdd failed = coalesce(failed, icollectArray(total[]*0) )

| fieldsAdd expression = failed[] / total[]

| summarize { expression = avg(expression[] ) }, by: { interval, timeframe }
| fieldsAdd expression = coalesce(expression[],0)
| sort arrayAvg(expression) desc&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are the components of it:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Use of&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;nonempty:true&lt;/STRONG&gt;&lt;/EM&gt; parameter ensures that there is always something returned by timeseries command. In case of query with &lt;EM&gt;&lt;STRONG&gt;by:&lt;/STRONG&gt;&lt;/EM&gt; record with null value of dimension will be provided.&lt;/LI&gt;&lt;LI&gt;I included entity filter in timeseries command. Having it after would eliminate special record produced by use of&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;nonempty:true&lt;/STRONG&gt;&lt;/EM&gt; parameter&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;&lt;STRONG&gt;kind:leftOuter&lt;/STRONG&gt;&lt;/EM&gt; was used to ensure when there are no "failed" requests, "total" timeseries is not eliminated&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;&lt;STRONG&gt;join&lt;/STRONG&gt;&lt;/EM&gt; command works this way, so record keyed by null will not be connected. To avoid this behavior we can wrap "dt.entity.service" in a record and use it in join condition&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd key=record(dt.entity.service)&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;In such case value of "failed" timeseries is null, so&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd failed = coalesce(failed, icollectArray(total[]*0) )&lt;/LI-CODE&gt;&lt;P class="lia-indent-padding-left-30px"&gt;makes sure we have array of zeroes instead&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;To avoid nulls being result of 0/0 division, they can be replaced with 0s:&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd expression = coalesce(expression[],0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2025 11:11:59 GMT</pubDate>
    <dc:creator>krzysztof_hoja</dc:creator>
    <dc:date>2025-01-23T11:11:59Z</dc:date>
    <item>
      <title>Transform "There are no records" into 0 with DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Transform-quot-There-are-no-records-quot-into-0-with-DQL/m-p/268083#M1629</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to transform the message "There are no records" in my tile to a single 0 (or an array of zeros).&lt;/P&gt;&lt;P&gt;I have tried using union:true, nonempty:true, and the coalesce function but none of them seem to work. I assume this is because the query uses 2 timeseries joined.&lt;/P&gt;&lt;P&gt;Is there a way to achieve this?&lt;/P&gt;&lt;P&gt;Here is my DQL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries count = sum(dt.service.request.count, default:0), by: { dt.entity.service }, filter: { failed == true }
| join [ timeseries count = sum(dt.service.request.count, default:0), by: { dt.entity.service } ], on: { dt.entity.service }, fields: { operand = count }
| filter { ( in(dt.entity.service, classicEntitySelector("type(service),tag(\"Kubernetes_ClusterName:payments\")"))) }
| fieldsAdd expression = count[] / operand[]
| fieldsRemove operand, count
| summarize { expression = avg(expression[] ) }, by: { interval, timeframe }
| sort arrayAvg(expression) desc&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 09:01:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Transform-quot-There-are-no-records-quot-into-0-with-DQL/m-p/268083#M1629</guid>
      <dc:creator>elenaperez</dc:creator>
      <dc:date>2025-01-22T09:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Transform "There are no records" into 0 with DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Transform-quot-There-are-no-records-quot-into-0-with-DQL/m-p/268214#M1634</link>
      <description>&lt;P&gt;&lt;SPAN&gt;"There are no records" message appears instead of chart in 2 cases:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Where result set is empty / no records returned &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;All timeseries to display contain only nulls / no values&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;To avoid this we need to make sure that there is always a result and it contains data. Null is valid value of timeseries which means no data, but it this it may be caused as a result of division of 0 by 0&lt;/P&gt;&lt;P&gt;Additionally there is another problem with join in this query: left query (&lt;EM&gt;&lt;STRONG&gt;timeseries&lt;/STRONG&gt;&lt;/EM&gt; with "failed == true" condition) will not return a timeseries for a specific service when there is no failed requests and this cause that a service will not be present in the final data at all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final query can look like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries total = sum(dt.service.request.count, default:0), nonempty:true,  by: { dt.entity.service }
, filter: { ( in(dt.entity.service, classicEntitySelector("type(service),tag(\"Kubernetes_ClusterName:payments\")")))  }
| fieldsAdd key=record(dt.entity.service)

| join [ 
  timeseries failed = sum(dt.service.request.count, default:0), nonempty:true, by: { dt.entity.service } 
  , filter: { failed == true and ( in(dt.entity.service, classicEntitySelector("type(service),tag(\"Kubernetes_ClusterName:payments\")"))) }
  | fieldsAdd key=record(dt.entity.service)

], on: { key }, fields: { failed }, kind:leftOuter

| fieldsAdd failed = coalesce(failed, icollectArray(total[]*0) )

| fieldsAdd expression = failed[] / total[]

| summarize { expression = avg(expression[] ) }, by: { interval, timeframe }
| fieldsAdd expression = coalesce(expression[],0)
| sort arrayAvg(expression) desc&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are the components of it:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Use of&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;nonempty:true&lt;/STRONG&gt;&lt;/EM&gt; parameter ensures that there is always something returned by timeseries command. In case of query with &lt;EM&gt;&lt;STRONG&gt;by:&lt;/STRONG&gt;&lt;/EM&gt; record with null value of dimension will be provided.&lt;/LI&gt;&lt;LI&gt;I included entity filter in timeseries command. Having it after would eliminate special record produced by use of&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;nonempty:true&lt;/STRONG&gt;&lt;/EM&gt; parameter&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;&lt;STRONG&gt;kind:leftOuter&lt;/STRONG&gt;&lt;/EM&gt; was used to ensure when there are no "failed" requests, "total" timeseries is not eliminated&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;&lt;STRONG&gt;join&lt;/STRONG&gt;&lt;/EM&gt; command works this way, so record keyed by null will not be connected. To avoid this behavior we can wrap "dt.entity.service" in a record and use it in join condition&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd key=record(dt.entity.service)&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;In such case value of "failed" timeseries is null, so&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd failed = coalesce(failed, icollectArray(total[]*0) )&lt;/LI-CODE&gt;&lt;P class="lia-indent-padding-left-30px"&gt;makes sure we have array of zeroes instead&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;To avoid nulls being result of 0/0 division, they can be replaced with 0s:&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd expression = coalesce(expression[],0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 11:11:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Transform-quot-There-are-no-records-quot-into-0-with-DQL/m-p/268214#M1634</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-01-23T11:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Transform "There are no records" into 0 with DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/Transform-quot-There-are-no-records-quot-into-0-with-DQL/m-p/273093#M1838</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/25373"&gt;@krzysztof_hoja&lt;/a&gt;,&amp;nbsp;is everything ok? I'm using a fetch events. It's not possible to use "nonempty:true", right?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2025 17:01:32 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Transform-quot-There-are-no-records-quot-into-0-with-DQL/m-p/273093#M1838</guid>
      <dc:creator>RPbiaggio</dc:creator>
      <dc:date>2025-03-20T17:01:32Z</dc:date>
    </item>
  </channel>
</rss>

