<?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 Assign Multiple Variables in DQL Queries Following Best Practices in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Assign-Multiple-Variables-in-DQL-Queries-Following-Best/m-p/273094#M1839</link>
    <description>&lt;DIV class=""&gt;I am working on a DQL query to gather and store 2 variables and then create a trending variable.&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;Please advise if this is the best way to solve this problem.&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Fetch Active problems from the last 7 days&lt;/DIV&gt;
&lt;DIV class=""&gt;fetch dt.davis.problems, from: now()-7d&lt;/DIV&gt;
&lt;DIV class=""&gt;| fieldsAdd entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| expand entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| filter event.status ==&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"ACTIVE"&lt;/DIV&gt;
&lt;DIV class=""&gt;| summarize count(), alias:last7DayCount&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Fetch Active problems from the 8-14 days ago&lt;/DIV&gt;
&lt;DIV class=""&gt;| append [fetch dt.davis.problems, from: now()-14d, to: now()-8d&lt;/DIV&gt;
&lt;DIV class=""&gt;| fieldsAdd entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| expand entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| filter event.status ==&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"ACTIVE"&lt;/DIV&gt;
&lt;DIV class=""&gt;| summarize count(), alias:last14DayCount]&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Combine results into a single output&lt;/DIV&gt;
&lt;DIV class=""&gt;| summarize sum(last7DayCount), alias:last7DayCount, sum(last14DayCount), alias:last14DayCount&lt;/DIV&gt;
&lt;DIV class=""&gt;| fields last7DayCount, last14DayCount&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Calculate trend using conditional logic with named parameters&lt;/DIV&gt;
&lt;DIV class=""&gt;| fieldsAdd trend =&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if(condition: last7DayCount &amp;gt; last14DayCount, then:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Up",&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;else:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if(condition: last7DayCount &amp;lt; last14DayCount, then:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Down",&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;else:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Stable"))&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Display results&lt;/DIV&gt;
&lt;DIV class=""&gt;| fields last14DayCount, last7DayCount, trend&lt;/DIV&gt;</description>
    <pubDate>Thu, 18 Dec 2025 12:18:28 GMT</pubDate>
    <dc:creator>Moonrox</dc:creator>
    <dc:date>2025-12-18T12:18:28Z</dc:date>
    <item>
      <title>Assign Multiple Variables in DQL Queries Following Best Practices</title>
      <link>https://community.dynatrace.com/t5/DQL/Assign-Multiple-Variables-in-DQL-Queries-Following-Best/m-p/273094#M1839</link>
      <description>&lt;DIV class=""&gt;I am working on a DQL query to gather and store 2 variables and then create a trending variable.&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;Please advise if this is the best way to solve this problem.&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Fetch Active problems from the last 7 days&lt;/DIV&gt;
&lt;DIV class=""&gt;fetch dt.davis.problems, from: now()-7d&lt;/DIV&gt;
&lt;DIV class=""&gt;| fieldsAdd entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| expand entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| filter event.status ==&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"ACTIVE"&lt;/DIV&gt;
&lt;DIV class=""&gt;| summarize count(), alias:last7DayCount&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Fetch Active problems from the 8-14 days ago&lt;/DIV&gt;
&lt;DIV class=""&gt;| append [fetch dt.davis.problems, from: now()-14d, to: now()-8d&lt;/DIV&gt;
&lt;DIV class=""&gt;| fieldsAdd entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| expand entity_tags&lt;/DIV&gt;
&lt;DIV class=""&gt;| filter event.status ==&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"ACTIVE"&lt;/DIV&gt;
&lt;DIV class=""&gt;| summarize count(), alias:last14DayCount]&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Combine results into a single output&lt;/DIV&gt;
&lt;DIV class=""&gt;| summarize sum(last7DayCount), alias:last7DayCount, sum(last14DayCount), alias:last14DayCount&lt;/DIV&gt;
&lt;DIV class=""&gt;| fields last7DayCount, last14DayCount&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Calculate trend using conditional logic with named parameters&lt;/DIV&gt;
&lt;DIV class=""&gt;| fieldsAdd trend =&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if(condition: last7DayCount &amp;gt; last14DayCount, then:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Up",&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;else:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if(condition: last7DayCount &amp;lt; last14DayCount, then:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Down",&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;else:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Stable"))&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;// Display results&lt;/DIV&gt;
&lt;DIV class=""&gt;| fields last14DayCount, last7DayCount, trend&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Dec 2025 12:18:28 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Assign-Multiple-Variables-in-DQL-Queries-Following-Best/m-p/273094#M1839</guid>
      <dc:creator>Moonrox</dc:creator>
      <dc:date>2025-12-18T12:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - Best Practice for Multiple Variable Assignment</title>
      <link>https://community.dynatrace.com/t5/DQL/Assign-Multiple-Variables-in-DQL-Queries-Following-Best/m-p/273363#M1852</link>
      <description>&lt;P&gt;I would suggest running a single fetch going back the full 14 days and then using summarize combined with countIf. This can be used to create two separate count, one for the last 7 days, and one for the prior 7 days (based on the start time perhaps). You can then use fieldsAdd with an if statement that compares the two counts to determine which way the trend is moving. I would also urge caution around the use of the expand command, as well as filtering on active==true in your query, as both of these might generate undesirable results depending on what you are trying to accomplish here.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 22:51:56 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Assign-Multiple-Variables-in-DQL-Queries-Following-Best/m-p/273363#M1852</guid>
      <dc:creator>marco_irmer</dc:creator>
      <dc:date>2025-03-24T22:51:56Z</dc:date>
    </item>
  </channel>
</rss>

