<?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 DQL percentage in a graph of two arrays (error versus total) in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/DQL-percentage-in-a-graph-of-two-arrays-error-versus-total/m-p/282578#M2391</link>
    <description>&lt;P&gt;Hi community! Struggling with the following - is it possible to create a percentage calculation and show it in a Dynatrace dashboard visualization (timeseries graph)?&lt;/P&gt;&lt;P&gt;I have the following working DQL that includes two arrays: total and errors:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch logs
| filter dt.system.bucket == "kpi"
| filter matchesValue(applicationid, "XXX")
| parse content, "JSON:json"
// several filters...
| expand errorCode = json[data][errorCode]
| fieldsAdd isError = if(isNotNull(errorCode), 1, else: 0)
| makeTimeseries {total = count(), errors = sum(isError)}, time:{timestamp}, interval:{24h}
| fieldsAdd errorRate = if(total &amp;gt; 0, round(errors * 100.0 / total, decimals: 2), else: 0)&lt;/LI-CODE&gt;&lt;P&gt;However the errorRate does not seem to work. Here is a snippet from the raw response:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "records": [
    {
      "timeframe": {
        "start": "2025-07-23T00:00:00.000000000+02:00",
        "end": "2025-07-31T00:00:00.000000000+02:00"
      },
      "interval": "86400000000000",
      "total": [
        73229,
        98446,
        88787,
        89492,
        95227,
        87934,
        85991,
        21596
      ],
      "errors": [
        4487,
        6250,
        5598,
        5856,
        6691,
        6580,
        5673,
        1278
      ],
      "errorRate": "0"
    }
  ],
  "types": [
    {
      "indexRange": [
        0,
        0
      ],
      "mappings": {
        "timeframe": {
          "type": "timeframe"
        },
        "interval": {
          "type": "duration"
        },
        "total": {
          "type": "array",
          "types": [
            {
              "indexRange": [
                0,
                7
              ],
              "mappings": {
                "element": {
                  "type": "double"
                }
              }
            }
          ]
        },
        "errors": {
          "type": "array",
          "types": [
            {
              "indexRange": [
                0,
                7
              ],
              "mappings": {
                "element": {
                  "type": "double"
                }
              }
            }
          ]
        },
        "errorRate": {
          "type": "long"
        }
      }
    }
  ],&lt;/LI-CODE&gt;&lt;P&gt;Do you know a way to make this work? Thanks.&lt;/P&gt;&lt;P&gt;Please note even when commenting out the last line, I can't get error and total to be visualized:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="revoke7889_0-1753857766276.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29274i29B0705B7246135B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="revoke7889_0-1753857766276.png" alt="revoke7889_0-1753857766276.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jul 2025 06:42:57 GMT</pubDate>
    <dc:creator>revoke7889</dc:creator>
    <dc:date>2025-07-30T06:42:57Z</dc:date>
    <item>
      <title>DQL percentage in a graph of two arrays (error versus total)</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-percentage-in-a-graph-of-two-arrays-error-versus-total/m-p/282578#M2391</link>
      <description>&lt;P&gt;Hi community! Struggling with the following - is it possible to create a percentage calculation and show it in a Dynatrace dashboard visualization (timeseries graph)?&lt;/P&gt;&lt;P&gt;I have the following working DQL that includes two arrays: total and errors:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch logs
| filter dt.system.bucket == "kpi"
| filter matchesValue(applicationid, "XXX")
| parse content, "JSON:json"
// several filters...
| expand errorCode = json[data][errorCode]
| fieldsAdd isError = if(isNotNull(errorCode), 1, else: 0)
| makeTimeseries {total = count(), errors = sum(isError)}, time:{timestamp}, interval:{24h}
| fieldsAdd errorRate = if(total &amp;gt; 0, round(errors * 100.0 / total, decimals: 2), else: 0)&lt;/LI-CODE&gt;&lt;P&gt;However the errorRate does not seem to work. Here is a snippet from the raw response:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "records": [
    {
      "timeframe": {
        "start": "2025-07-23T00:00:00.000000000+02:00",
        "end": "2025-07-31T00:00:00.000000000+02:00"
      },
      "interval": "86400000000000",
      "total": [
        73229,
        98446,
        88787,
        89492,
        95227,
        87934,
        85991,
        21596
      ],
      "errors": [
        4487,
        6250,
        5598,
        5856,
        6691,
        6580,
        5673,
        1278
      ],
      "errorRate": "0"
    }
  ],
  "types": [
    {
      "indexRange": [
        0,
        0
      ],
      "mappings": {
        "timeframe": {
          "type": "timeframe"
        },
        "interval": {
          "type": "duration"
        },
        "total": {
          "type": "array",
          "types": [
            {
              "indexRange": [
                0,
                7
              ],
              "mappings": {
                "element": {
                  "type": "double"
                }
              }
            }
          ]
        },
        "errors": {
          "type": "array",
          "types": [
            {
              "indexRange": [
                0,
                7
              ],
              "mappings": {
                "element": {
                  "type": "double"
                }
              }
            }
          ]
        },
        "errorRate": {
          "type": "long"
        }
      }
    }
  ],&lt;/LI-CODE&gt;&lt;P&gt;Do you know a way to make this work? Thanks.&lt;/P&gt;&lt;P&gt;Please note even when commenting out the last line, I can't get error and total to be visualized:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="revoke7889_0-1753857766276.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29274i29B0705B7246135B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="revoke7889_0-1753857766276.png" alt="revoke7889_0-1753857766276.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jul 2025 06:42:57 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-percentage-in-a-graph-of-two-arrays-error-versus-total/m-p/282578#M2391</guid>
      <dc:creator>revoke7889</dc:creator>
      <dc:date>2025-07-30T06:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: DQL percentage in a graph of two arrays (error versus total)</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-percentage-in-a-graph-of-two-arrays-error-versus-total/m-p/282903#M2403</link>
      <description>&lt;P&gt;Last line should look like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd errorRate = if(total[] &amp;gt; 0, round(errors[] * 100.0 / total[], decimals: 2), else: 0)&lt;/LI-CODE&gt;&lt;P&gt;you can find more information on iterative expressions here:&amp;nbsp;&lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/operators#iterative-expressions" target="_blank"&gt;https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/operators#iterative-expressions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;My result on slightly different data, but with 2 last lines kept:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1754251764751.png" style="width: 872px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29346i423DAAE66E271595/image-dimensions/872x249?v=v2" width="872" height="249" role="button" title="krzysztof_hoja_0-1754251764751.png" alt="krzysztof_hoja_0-1754251764751.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Aug 2025 20:09:45 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-percentage-in-a-graph-of-two-arrays-error-versus-total/m-p/282903#M2403</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-08-03T20:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: DQL percentage in a graph of two arrays (error versus total)</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-percentage-in-a-graph-of-two-arrays-error-versus-total/m-p/283052#M2408</link>
      <description>&lt;P&gt;Thanks, working!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 07:30:30 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-percentage-in-a-graph-of-two-arrays-error-versus-total/m-p/283052#M2408</guid>
      <dc:creator>revoke7889</dc:creator>
      <dc:date>2025-08-05T07:30:30Z</dc:date>
    </item>
  </channel>
</rss>

