<?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: DAX Query to Group by and Join in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-to-Group-by-and-Join/m-p/4627108#M177136</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1246289" data-lia-user-login="---Andrea---" class="lia-mention lia-mention-user"&gt;---Andrea---&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for being part of the Microsoft Fabric Community.&lt;/P&gt;
&lt;P&gt;Please find below DAX code as per your requirement.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;***********************************************&lt;/STRONG&gt;&lt;BR /&gt;left join =&lt;/P&gt;
&lt;P&gt;VAR A=&lt;BR /&gt;SELECTEDCOLUMNS(ae,"Infants",ae[Infants])&lt;BR /&gt;VAR B=&lt;BR /&gt;SELECTEDCOLUMNS(dm,"UCRFID",dm[UCRFID])&lt;BR /&gt;return&lt;BR /&gt;NATURALLEFTOUTERJOIN(B,A)&lt;/P&gt;
&lt;P&gt;VAR IR =&lt;/P&gt;
&lt;P&gt;IF(&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ISBLANK(DIVIDE ( COUNTROWS ( RELATEDTABLE ( AE ) ), DM[Duration])),0&lt;/P&gt;
&lt;P&gt;)&lt;BR /&gt;return IR&lt;/P&gt;
&lt;P&gt;Infants count= COUNTROWS( AE )&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;***********************************************&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;If the above information helps you, please give us a Kudos and marked the Accept as a solution.&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Best Regards,&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Community Support Team _ C Srikanth.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Mar 2025 09:02:14 GMT</pubDate>
    <dc:creator>v-csrikanth</dc:creator>
    <dc:date>2025-03-27T09:02:14Z</dc:date>
    <item>
      <title>DAX Query to Group by and Join</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-to-Group-by-and-Join/m-p/4626155#M177087</link>
      <description>&lt;P&gt;Good afternoon, I need to convert a short SQL query to PowerBI DAX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a reference, here is the SQL query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;WITH ae_per_infant AS (
    SELECT
        Infants,
        COUNT(*) AS Count
    FROM
        ae
    GROUP BY
        Infants
)

SELECT
    dm.UCRFID AS UCRFID,
    ae_per_infant.Count AS Count,
    COALESCE(ae_per_infant.Count / dm.duration, 0) AS IR
FROM
    dm
LEFT JOIN
    ae_per_infant ON dm.UCRFID = ae_per_infant.Infants&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As you can see, the operations are a groupby-aggregate, a join and a simple column operation.&lt;/DIV&gt;&lt;DIV&gt;In PowerBI, there is an existing 1-to-many relation between DM and AE with bi-directional filtering active.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In my case, since I need this table to update based on filters, I can't perform the calculation in PowerQuery M in advance. To my knowledge, I can only use DAX.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 15:38:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-to-Group-by-and-Join/m-p/4626155#M177087</guid>
      <dc:creator>---Andrea---</dc:creator>
      <dc:date>2025-03-26T15:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Query to Group by and Join</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-to-Group-by-and-Join/m-p/4626245#M177088</link>
      <description>&lt;P&gt;Change the relationship so that it is single direction - bi-directional relationships are almost never a good idea.&lt;/P&gt;
&lt;P&gt;You can create a couple of measures like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Infant count = COUNTROWS( AE )

IR =
SUMX ( DM, DIVIDE ( COUNTROWS ( RELATEDTABLE ( AE ) ), DM[Duration], 0 ) )
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Mar 2025 16:25:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-to-Group-by-and-Join/m-p/4626245#M177088</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-03-26T16:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Query to Group by and Join</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-to-Group-by-and-Join/m-p/4627108#M177136</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1246289" data-lia-user-login="---Andrea---" class="lia-mention lia-mention-user"&gt;---Andrea---&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for being part of the Microsoft Fabric Community.&lt;/P&gt;
&lt;P&gt;Please find below DAX code as per your requirement.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;***********************************************&lt;/STRONG&gt;&lt;BR /&gt;left join =&lt;/P&gt;
&lt;P&gt;VAR A=&lt;BR /&gt;SELECTEDCOLUMNS(ae,"Infants",ae[Infants])&lt;BR /&gt;VAR B=&lt;BR /&gt;SELECTEDCOLUMNS(dm,"UCRFID",dm[UCRFID])&lt;BR /&gt;return&lt;BR /&gt;NATURALLEFTOUTERJOIN(B,A)&lt;/P&gt;
&lt;P&gt;VAR IR =&lt;/P&gt;
&lt;P&gt;IF(&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ISBLANK(DIVIDE ( COUNTROWS ( RELATEDTABLE ( AE ) ), DM[Duration])),0&lt;/P&gt;
&lt;P&gt;)&lt;BR /&gt;return IR&lt;/P&gt;
&lt;P&gt;Infants count= COUNTROWS( AE )&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;***********************************************&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;If the above information helps you, please give us a Kudos and marked the Accept as a solution.&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Best Regards,&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Community Support Team _ C Srikanth.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 09:02:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Query-to-Group-by-and-Join/m-p/4627108#M177136</guid>
      <dc:creator>v-csrikanth</dc:creator>
      <dc:date>2025-03-27T09:02:14Z</dc:date>
    </item>
  </channel>
</rss>

