<?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: Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845171#M39279</link>
    <description>&lt;P&gt;Please provide sanitized sample data that fully covers your issue. &lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Oct 2022 22:22:08 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-10-16T22:22:08Z</dc:date>
    <item>
      <title>Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2841715#M39252</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have the following table, which shows MH(Mental Health type)&amp;nbsp; -&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;SA (Substance Abuse type) diagnoses for a particular client:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This table has over 200K records. The data used in this topic (below) is just an example&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;tbl Diagnosis:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ProgramID&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;ClientID&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Diagnosis_Desc&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Diagnosis_Cat&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;666&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;7/1/2018&lt;/TD&gt;&lt;TD&gt;Bi-Polar&lt;/TD&gt;&lt;TD&gt;MH&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;666&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;8/1/2018&lt;/TD&gt;&lt;TD&gt;Alcohol&lt;/TD&gt;&lt;TD&gt;SA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;888&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;6/1/2018&lt;/TD&gt;&lt;TD&gt;Cocaine&lt;/TD&gt;&lt;TD&gt;SA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;999&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;7/1/2019&lt;/TD&gt;&lt;TD&gt;Scizophrenia&lt;/TD&gt;&lt;TD&gt;MH&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;999&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;8/1/2019&lt;/TD&gt;&lt;TD&gt;Alcohol&lt;/TD&gt;&lt;TD&gt;SA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;222&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;7/1/2020&lt;/TD&gt;&lt;TD&gt;Nicotine&lt;/TD&gt;&lt;TD&gt;SA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;222&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;8/1/2020&lt;/TD&gt;&lt;TD&gt;PTSD&lt;/TD&gt;&lt;TD&gt;MH&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;222&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;9/1/2020&lt;/TD&gt;&lt;TD&gt;Stress&lt;/TD&gt;&lt;TD&gt;MH&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Below is the screenshot of the same tbl ( more visible format)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Diagnosis.PNG" style="width: 546px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/803983iCA86767F5C68B2D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Diagnosis.PNG" alt="Diagnosis.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have a calculated column in this table, which calculates number of&amp;nbsp; Diagnosis categories - SA/MH per client:&lt;/P&gt;&lt;P&gt;So, if I populate my data in Power BI, with [# Category per Client] measure,&amp;nbsp; it'll look as:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DiagnosisPBI.PNG" style="width: 674px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/803984i71FFDA126722615B/image-size/large?v=v2&amp;amp;px=999" role="button" title="DiagnosisPBI.PNG" alt="DiagnosisPBI.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My goal is to create a Cross Matrix table, where&lt;/P&gt;&lt;P&gt;X axis = SA diagnosis,&lt;/P&gt;&lt;P&gt;Y axis = MH diagnosis,&lt;/P&gt;&lt;P&gt;value = # of Clients that have a SA-MH diagnosis pair (crossed pair).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I created 2 calculated tables with the unduplicated MH / SA categories -&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;zzParam_SA:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SA.PNG" style="width: 144px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/803990iF85FA6EF1801E175/image-size/large?v=v2&amp;amp;px=999" role="button" title="SA.PNG" alt="SA.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;zz_Param_MH:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MH.PNG" style="width: 165px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/803991iFFCFD6C75CA8EA8A/image-size/large?v=v2&amp;amp;px=999" role="button" title="MH.PNG" alt="MH.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To calculate a Measure for the Cross Matrix I used the following code (adviced by a member of this community):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _ADDCOLUMN = ADDCOLUMNS('Diagnosis',"Flag",IF([Diagnosis_Desc] = MAX(zzParam_MH[MH]) || 
                             [Diagnosis_Desc] = MAX(zzParam_SA[SA]),1,0))
VAR _SUMMAIZE = 
 SUMMARIZE(_ADDCOLUMN,[ClientWHID],"Sum",               
            SUMX(FILTER(_ADDCOLUMN,'Diagnosis'[ClientWHID] = 
                  EARLIER('DDiagnosis'[ClientWHID])),[Flag]))
RETURN
COUNTAX(FILTER(_SUMMAIZE,[Sum]=2),[ClientWHID])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It works perfectly, but if there is no ProgramID, Date columns in my dataset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(Only if there is [ClientID], [Diagnosis_Desc], [Diagnosis_Cat], [# Category per Client] columns)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I need [Date] / [ProgramID] included in this dataset, as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to add these 2 columns after the first SUMMARIZE, but it didn't work correctly &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(shows incorrect number or cross-paired ClientIDs).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expect to see the following numbers in my matrix (as shown in the picture below):&lt;/P&gt;&lt;P&gt;Alcohol-Bi-Polar = 1 Client (ClientID 22);&lt;/P&gt;&lt;P&gt;Alcohol-Scizophrenia = 1 Client (ClientID 24)&lt;/P&gt;&lt;P&gt;Nicotine-PTSD = 1 Client (ClientID 25)&lt;/P&gt;&lt;P&gt;Nicotine-Stress = 1 Client (ClientID 25)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all the other SA-MH combinations have no clients (0), so they're not shown.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cross Matrix.PNG" style="width: 340px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/804039i877C34BC377759EC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cross Matrix.PNG" alt="Cross Matrix.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help me correctly modify the measure, so it would work as above, but if there is also ProgramID, Date added in my&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dataset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks, as always!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 02:07:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2841715#M39252</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2022-10-17T02:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845171#M39279</link>
      <description>&lt;P&gt;Please provide sanitized sample data that fully covers your issue. &lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2022 22:22:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845171#M39279</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-10-16T22:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845196#M39280</link>
      <description>&lt;P&gt;To Ibendlin -&lt;/P&gt;&lt;P&gt;The Diagnosis tbl I pasted in this topic - fully covers my issue and it is sanitized&lt;/P&gt;&lt;P&gt;The outcome I expect to have is also provided in this post!&lt;BR /&gt;&lt;BR /&gt;Since I don't see a responses and since your comment shows problem in this post&lt;/P&gt;&lt;P&gt;I'll delete this one and will try to describe my goal in more obvious way.&lt;/P&gt;&lt;P&gt;I'll also attach the actual table example&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2022 22:57:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845196#M39280</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2022-10-16T22:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845219#M39281</link>
      <description>&lt;P&gt;Please provide source data in usable format. Screenshots are not a usable format.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2022 23:16:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845219#M39281</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-10-16T23:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845322#M39285</link>
      <description>&lt;P&gt;Ok, I just did!&lt;/P&gt;&lt;P&gt;Updated the original post adding the same tbl into it&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 02:08:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2845322#M39285</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2022-10-17T02:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2846869#M39291</link>
      <description>&lt;P&gt;here's your starting point:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cross = CROSSJOIN(
SELECTCOLUMNS( CALCULATETABLE(values(Diagnosis[Diagnosis_Desc  ]),Diagnosis[Diagnosis_Cat  ]="MH"),"MH",Diagnosis[Diagnosis_Desc  ]),
SELECTCOLUMNS( CALCULATETABLE(values(Diagnosis[Diagnosis_Desc  ]),Diagnosis[Diagnosis_Cat  ]="SA"),"SA",Diagnosis[Diagnosis_Desc  ]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then you can add the measure to compute the number of clients that have both. That measure will then honor all your other filters.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Val = countrows(INTERSECT(SELECTCOLUMNS(filter(Diagnosis,Diagnosis[Diagnosis_Desc  ]=SELECTEDVALUE(Cross[MH])),"CI",Diagnosis[ClientID  ]),SELECTCOLUMNS(filter(Diagnosis,Diagnosis[Diagnosis_Desc  ]=SELECTEDVALUE(Cross[SA])),"CI",Diagnosis[ClientID  ])))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lbendlin_0-1666018608511.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/805386iC3E090DAAF531E1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lbendlin_0-1666018608511.png" alt="lbendlin_0-1666018608511.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see the totals don't work - not sure if that is important for you. If it is then the measure needs to be modified a bit.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 14:57:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2846869#M39291</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-10-17T14:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Cross Matrix table in Power BI DAX - need to count number of Clients for a specific value</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2848243#M39307</link>
      <description>&lt;P&gt;Ibendlin, Thank you It worked!&lt;BR /&gt;Also, Distinct () can be added after Countrows () if there multiple Diagnosis_Desc&lt;/P&gt;&lt;P&gt;That way it's calculating unique values!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 06:45:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cross-Matrix-table-in-Power-BI-DAX-need-to-count-number-of/m-p/2848243#M39307</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2022-10-18T06:45:52Z</dc:date>
    </item>
  </channel>
</rss>

