<?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 To retrieve MAX / MIN using a measure on aggregated level(s) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-To-retrieve-MAX-MIN-using-a-measure-on-aggregated-level-s/m-p/3868349#M151120</link>
    <description>&lt;P&gt;Hello Owen, thank you very much for both..., the source to learn from and the pbix to work with.&lt;/P&gt;&lt;P&gt;Works fine and the topic is solved.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
    <pubDate>Thu, 25 Apr 2024 12:36:32 GMT</pubDate>
    <dc:creator>thomasreick</dc:creator>
    <dc:date>2024-04-25T12:36:32Z</dc:date>
    <item>
      <title>How To retrieve MAX / MIN using a measure on aggregated level(s)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-To-retrieve-MAX-MIN-using-a-measure-on-aggregated-level-s/m-p/3864654#M150972</link>
      <description>&lt;P&gt;Hello there&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;I am actually working with Callcenter-Data.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;I need help to create measures returning&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;... the name of the CC-Agent with the Max Number of Calls per week&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;... the name of the CC-Agent with the Min Number of Calls per week&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;Each should be displayed on a Card Visual&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;One problem is that I do not find a way to calculate the max with a direct use of a metric figure (I countrows(facts) which represents the incoming phone number), but MAX() requires a table, not an aggregate.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;My Measure does not work&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;MaxCallPerAgent =&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;vTbl&lt;/SPAN&gt; = &lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;( &lt;SPAN&gt;dimAgents&lt;/SPAN&gt;, &lt;SPAN&gt;"@Calls"&lt;/SPAN&gt;, &lt;SPAN&gt;[#Calls]&lt;/SPAN&gt; &amp;nbsp;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;vMax_v1&lt;/SPAN&gt; = &lt;SPAN&gt;MAX&lt;/SPAN&gt;( &lt;SPAN&gt;dimAgents&lt;/SPAN&gt;&lt;SPAN&gt;[@Calls]&lt;/SPAN&gt; ) &lt;SPAN&gt;-- does not work, no field [@Calls in table]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;vMax_v2&lt;/SPAN&gt; = &lt;SPAN&gt;MAX&lt;/SPAN&gt;( &lt;SPAN&gt;vTbl&lt;/SPAN&gt;&lt;SPAN&gt;[@Calls]&lt;/SPAN&gt; ) &lt;SPAN&gt;-- does not work, vTbl not allowed&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;VAR Max_Topn = TOPN(1, vTbl, [@Calls], DESC ) -- gives no scalar value&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;???&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;I have tried some approaches but unfortunately I do not succeed&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;A href="https://reickconsulting-my.sharepoint.com/:u:/g/personal/thomas_reick_reick-consulting_de/Ed7wwHIoVm5Kn741m21H1bgBRd86j8_vUcbnmIoS6wLYdw?e=1E0L5f" target="_blank" rel="noopener"&gt;callcenter.pbix&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;The link leads to a pbix on my OneDrive with a reduced datamodel.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;Your help is appreciated.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;Thx &amp;amp; brgds&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;Thomas&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 08:04:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-To-retrieve-MAX-MIN-using-a-measure-on-aggregated-level-s/m-p/3864654#M150972</guid>
      <dc:creator>thomasreick</dc:creator>
      <dc:date>2024-04-24T08:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: How To retrieve MAX / MIN using a measure on aggregated level(s)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-To-retrieve-MAX-MIN-using-a-measure-on-aggregated-level-s/m-p/3865167#M150990</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="305272" data-lia-user-login="thomasreick" class="lia-mention lia-mention-user"&gt;thomasreick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some variations on how you can create such a measure (modified PBIX attached).&lt;/P&gt;
&lt;P&gt;Showing examples for Agent with Max # Calls:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Agent with Max Calls FIRSTNONBLANK TOPN = 
-- FIRSTNONBLANK breaks ties by choosing first Agent lexicographically in the case of ties
FIRSTNONBLANK (
    TOPN ( 1, VALUES ( dimAgents[AgentName] ), [#Calls] ),
    0
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Agent with Max Calls CONCATENATEX TOPN = 
-- CONCATENATEX concatenates multiple AgentNames in the case of ties
CONCATENATEX (
    TOPN ( 1, VALUES ( dimAgents[AgentName] ), [#Calls] ),
    dimAgents[AgentName],
    ", ",
    dimAgents[AgentName]
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Agent with Max Calls FIRSTNONBLANK INDEX = 
-- FIRSTNONBLANK breaks ties by choosing first Agent lexicographically in the case of ties
FIRSTNONBLANK (
    INDEX (
        1,
        VALUES ( dimAgents[AgentName] ),
        ORDERBY ( [#Calls], DESC )
    ),
    0
)&lt;/LI-CODE&gt;
&lt;P&gt;Here is an example of the values returned in your sample PBIX when filtered on ISO Week 202402 where there is a tie for agent with Min calls:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a good article on this topic:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/alternative-use-of-firstnonblank-and-lastnonblank/" target="_blank"&gt;https://www.sqlbi.com/articles/alternative-use-of-firstnonblank-and-lastnonblank/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 10:56:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-To-retrieve-MAX-MIN-using-a-measure-on-aggregated-level-s/m-p/3865167#M150990</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2024-04-24T10:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: How To retrieve MAX / MIN using a measure on aggregated level(s)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-To-retrieve-MAX-MIN-using-a-measure-on-aggregated-level-s/m-p/3868349#M151120</link>
      <description>&lt;P&gt;Hello Owen, thank you very much for both..., the source to learn from and the pbix to work with.&lt;/P&gt;&lt;P&gt;Works fine and the topic is solved.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 12:36:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-To-retrieve-MAX-MIN-using-a-measure-on-aggregated-level-s/m-p/3868349#M151120</guid>
      <dc:creator>thomasreick</dc:creator>
      <dc:date>2024-04-25T12:36:32Z</dc:date>
    </item>
  </channel>
</rss>

