<?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: How can I reuse a custom metric in DQL without reinitializing it multiple times? in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282260#M2375</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/87812"&gt;@knallapa&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;You can set up the common thing in all queries as variable and reference it in dashboard tiles.&lt;BR /&gt;&lt;A href="https://docs.dynatrace.com/docs/analyze-explore-automate/dashboards-and-notebooks/dashboards-new/components/dashboard-component-variable" target="_blank"&gt;Reference: Add a variable to a dashboard — Dynatrace Docs&lt;/A&gt;&lt;BR /&gt;You can add as many variables as you want to. Maybe set up one variable for totalTransactions then use that in calculations. Set up a constant timeframe for that variable and let the other tiles have dashboard timeframe.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/76275"&gt;@Maheedhar_T&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jul 2025 19:23:13 GMT</pubDate>
    <dc:creator>Maheedhar_T</dc:creator>
    <dc:date>2025-07-24T19:23:13Z</dc:date>
    <item>
      <title>Reuse Custom Metrics in DQL Without Reinitialisation</title>
      <link>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282256#M2374</link>
      <description>&lt;P&gt;I'm currently using this query to reuse the same custom metric at different time intervals to populate table data in my dashboard. However, I’d like to simplify the query and reuse a variable multiple times with different conditions in DQL. Is there a better way to structure this?&lt;/P&gt;
&lt;P&gt;timeseries METRIC_A_approved = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeA" AND&lt;BR /&gt;(responseCode == "0" OR responseCode == "00") AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_A_total = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeA" AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_A_total }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_approved = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;(responseCode == "0" OR responseCode == "00") AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_approved }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_total = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_total }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_approved_subgroup = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;(responseCode == "0" OR responseCode == "00") AND&lt;BR /&gt;(categoryCode in ["1001", "1002", "1003", "1004", "1005"]) AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_approved_subgroup }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_total_subgroup = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;(categoryCode in ["1001", "1002", "1003", "1004", "1005"]) AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_total_subgroup }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_approved_domestic = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;(responseCode == "0" OR responseCode == "00") AND&lt;BR /&gt;categoryCode == "2001" AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_approved_domestic }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_total_domestic = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;categoryCode == "2001" AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_total_domestic }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_approved_crossborder = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;(responseCode == "0" OR responseCode == "00") AND&lt;BR /&gt;categoryCode == "2002" AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_approved_crossborder }, kind: outer&lt;/P&gt;
&lt;P&gt;| join [&lt;BR /&gt;timeseries METRIC_B_total_crossborder = sum(&lt;BR /&gt;`custom.app-metrics.transaction.data`,&lt;BR /&gt;scalar: true,&lt;BR /&gt;filter: {&lt;BR /&gt;txType == "TypeB" AND&lt;BR /&gt;categoryCode == "2002" AND&lt;BR /&gt;(isNull($Entity) OR $Entity == "" OR entity == $Entity)&lt;BR /&gt;}&lt;BR /&gt;), by: { entity }&lt;BR /&gt;], on: { entity }, fields: { METRIC_B_total_crossborder }, kind: outer&lt;/P&gt;
&lt;P&gt;| fieldsAdd&lt;BR /&gt;Rate_A = if(coalesce(METRIC_A_total, 0) == 0, 0, 100 * coalesce(METRIC_A_approved, 0) / coalesce(METRIC_A_total, 0)),&lt;BR /&gt;Rate_B = if(coalesce(METRIC_B_total, 0) == 0, 0, 100 * coalesce(METRIC_B_approved, 0) / coalesce(METRIC_B_total, 0)),&lt;BR /&gt;Rate_B_subgroup = if(coalesce(METRIC_B_total_subgroup, 0) == 0, 0, 100 * coalesce(METRIC_B_approved_subgroup, 0) / coalesce(METRIC_B_total_subgroup, 0)),&lt;BR /&gt;Rate_B_domestic = if(coalesce(METRIC_B_total_domestic, 0) == 0, 0, 100 * coalesce(METRIC_B_approved_domestic, 0) / coalesce(METRIC_B_total_domestic, 0)),&lt;BR /&gt;Rate_B_crossborder = if(coalesce(METRIC_B_total_crossborder, 0) == 0, 0, 100 * coalesce(METRIC_B_approved_crossborder, 0) / coalesce(METRIC_B_total_crossborder, 0))&lt;/P&gt;
&lt;P&gt;| filter not(isNull(entity) or entity == "")&lt;BR /&gt;| fieldsAdd&lt;BR /&gt;Entity = entity,&lt;BR /&gt;A.Total = toLong(coalesce(METRIC_A_total, 0)),&lt;BR /&gt;A.Rate = concat(toString(round(coalesce(Rate_A, 0), decimals: 2)), "%"),&lt;BR /&gt;B.Total = toLong(coalesce(METRIC_B_total, 0)),&lt;BR /&gt;B.Rate = concat(toString(round(coalesce(Rate_B, 0), decimals: 2)), "%"),&lt;BR /&gt;B.Total.Sub = toLong(coalesce(METRIC_B_total_subgroup, 0)),&lt;BR /&gt;B.Rate.Sub = concat(toString(round(coalesce(Rate_B_subgroup, 0), decimals: 2)), "%"),&lt;BR /&gt;B.Total.Dom = toLong(coalesce(METRIC_B_total_domestic, 0)),&lt;BR /&gt;B.Rate.Dom = concat(toString(round(coalesce(Rate_B_domestic, 0), decimals: 2)), "%"),&lt;BR /&gt;B.Total.XB = toLong(coalesce(METRIC_B_total_crossborder, 0)),&lt;BR /&gt;B.Rate.XB = concat(toString(round(coalesce(Rate_B_crossborder, 0), decimals: 2)), "%")&lt;/P&gt;
&lt;P&gt;| fields Entity, A.Total, A.Rate, B.Total, B.Rate, B.Total.Dom, B.Rate.Dom, B.Total.XB, B.Rate.XB, B.Total.Sub, B.Rate.Sub&lt;BR /&gt;| sort A.Rate desc&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Dec 2025 13:44:03 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282256#M2374</guid>
      <dc:creator>knallapa</dc:creator>
      <dc:date>2025-12-17T13:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reuse a custom metric in DQL without reinitializing it multiple times?</title>
      <link>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282260#M2375</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/87812"&gt;@knallapa&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;You can set up the common thing in all queries as variable and reference it in dashboard tiles.&lt;BR /&gt;&lt;A href="https://docs.dynatrace.com/docs/analyze-explore-automate/dashboards-and-notebooks/dashboards-new/components/dashboard-component-variable" target="_blank"&gt;Reference: Add a variable to a dashboard — Dynatrace Docs&lt;/A&gt;&lt;BR /&gt;You can add as many variables as you want to. Maybe set up one variable for totalTransactions then use that in calculations. Set up a constant timeframe for that variable and let the other tiles have dashboard timeframe.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/76275"&gt;@Maheedhar_T&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 19:23:13 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282260#M2375</guid>
      <dc:creator>Maheedhar_T</dc:creator>
      <dc:date>2025-07-24T19:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reuse a custom metric in DQL without reinitializing it multiple times?</title>
      <link>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282262#M2376</link>
      <description>&lt;P&gt;Sure, I will try in that direction. Thankyou&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/76275"&gt;@Maheedhar_T&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 19:31:20 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282262#M2376</guid>
      <dc:creator>knallapa</dc:creator>
      <dc:date>2025-07-24T19:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reuse a custom metric in DQL without reinitializing it multiple times?</title>
      <link>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282663#M2392</link>
      <description>&lt;P&gt;For Above Query Nothing worked for me: Tried variables, Problems i faced is :&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;can’t fetch a metric once and reuse it with conditional logic applying filters.&lt;/LI&gt;&lt;LI&gt;can’t assign a timeseries result to a variable inside fetch.&lt;/LI&gt;&lt;LI&gt;can’t use let to define reusable filters inside fetch.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Moreover variables have limits. other issue was variables i can't extend and apply filter conditions to that variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 04:24:12 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Reuse-Custom-Metrics-in-DQL-Without-Reinitialisation/m-p/282663#M2392</guid>
      <dc:creator>knallapa</dc:creator>
      <dc:date>2025-07-31T04:24:12Z</dc:date>
    </item>
  </channel>
</rss>

