<?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 Conditioning on an aggregated value in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Conditioning-on-an-aggregated-value/m-p/225235#M293</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;I have a question regarding a query using an If() statement.&lt;BR /&gt;Query:&lt;BR /&gt;fetch logs, scanLimitGBytes: -1&lt;BR /&gt;| filter matchesPhrase(content,"*******") OR matchesPhrase(content,"******")&lt;BR /&gt;| filter matchesPhrase(content,"*ACCESS")&lt;BR /&gt;| parse content, "************-'"&lt;BR /&gt;| filter channel != "null"&lt;BR /&gt;| summarize count=count(),by:{channel}&lt;BR /&gt;&lt;BR /&gt;Result is screenshot. My question is, my customer wants to add another field such as "isLive" that has the value TRUE, if and only if the count() value is the greatest amount all records. In the example shown, a value of true would appear next to the blue channel because the count() is the maximum among both records. I've been trying this with an if() statement with no results because they cannot contain aggregations. Any ideas of how to accomplish this? Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 12 Oct 2023 17:54:52 GMT</pubDate>
    <dc:creator>ryan-balcerzak</dc:creator>
    <dc:date>2023-10-12T17:54:52Z</dc:date>
    <item>
      <title>Conditioning on an aggregated value</title>
      <link>https://community.dynatrace.com/t5/DQL/Conditioning-on-an-aggregated-value/m-p/225235#M293</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;I have a question regarding a query using an If() statement.&lt;BR /&gt;Query:&lt;BR /&gt;fetch logs, scanLimitGBytes: -1&lt;BR /&gt;| filter matchesPhrase(content,"*******") OR matchesPhrase(content,"******")&lt;BR /&gt;| filter matchesPhrase(content,"*ACCESS")&lt;BR /&gt;| parse content, "************-'"&lt;BR /&gt;| filter channel != "null"&lt;BR /&gt;| summarize count=count(),by:{channel}&lt;BR /&gt;&lt;BR /&gt;Result is screenshot. My question is, my customer wants to add another field such as "isLive" that has the value TRUE, if and only if the count() value is the greatest amount all records. In the example shown, a value of true would appear next to the blue channel because the count() is the maximum among both records. I've been trying this with an if() statement with no results because they cannot contain aggregations. Any ideas of how to accomplish this? Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Oct 2023 17:54:52 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Conditioning-on-an-aggregated-value/m-p/225235#M293</guid>
      <dc:creator>ryan-balcerzak</dc:creator>
      <dc:date>2023-10-12T17:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning on an aggregated value</title>
      <link>https://community.dynatrace.com/t5/DQL/Conditioning-on-an-aggregated-value/m-p/225252#M295</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/66862"&gt;@ryan-balcerzak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This query should work.&lt;/P&gt;
&lt;P&gt;and please check out following youtube video where I explain how the last part of the query is crafted:&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=Lgv5rxlEJ0Q" target="_blank"&gt;https://www.youtube.com/watch?v=Lgv5rxlEJ0Q&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 16:17:47 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Conditioning-on-an-aggregated-value/m-p/225252#M295</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-10-12T16:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditioning on an aggregated value</title>
      <link>https://community.dynatrace.com/t5/DQL/Conditioning-on-an-aggregated-value/m-p/225258#M296</link>
      <description>&lt;P&gt;Here is what the query looked like as a final solution:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;fetch logs, scanLimitGBytes: -1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| filter matchesPhrase(content,"*********") OR matchesPhrase(content,"**********") &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| filter matchesPhrase(content,"*ACCESS") &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| parse content, "*************-'"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| filter channel != "null" | summarize count=count(),by:{channel} &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| summarize array = collectArray(record(channel=channel, count=count)), count = collectArray(count) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| fieldsAdd count_max = arrayMax(count) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| expand array&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| fields `Channel` = array[channel], `count`=array[count], isLive = if(array[count] == count_max, "&lt;/SPAN&gt;&lt;SPAN&gt;&lt;span class="lia-unicode-emoji" title=":red_circle:"&gt;🔴&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN&gt;")&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 17:55:46 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Conditioning-on-an-aggregated-value/m-p/225258#M296</guid>
      <dc:creator>ryan-balcerzak</dc:creator>
      <dc:date>2023-10-12T17:55:46Z</dc:date>
    </item>
  </channel>
</rss>

