<?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: Cumulative distinctcount incorrect on blank rows in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963044#M42989</link>
    <description>&lt;P&gt;You have to show more than what you have. Certainly, my formula is totally correct for the table shown and I can&amp;nbsp; totally prove it. If it does not work for you, it means you've got something in there that is different than what you've shown.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jul 2021 21:36:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-07-16T21:36:08Z</dc:date>
    <item>
      <title>DAX: Cumulative distinctcount incorrect on blank rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1962637#M42958</link>
      <description>&lt;P&gt;Hi, I am unable to get a correct cumulative distinctcount, because my table has blank rows for some columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula for NoStudents I used is:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DISTINCTCOUNTNOBLANK(MyTable[NoStudents]),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FILTER(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ALL(MyTable[Duration])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;, MyTable[Duration] &amp;lt;= MAX(MyTable[Duration])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;In the example below, what I would expect is that&amp;nbsp;CumStudents y1 for the Duration 4&amp;nbsp; &amp;amp; 5 years would be 35 and not 5.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Does anyone know how to solve this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MyTable:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Duration (years)&lt;/TD&gt;&lt;TD&gt;NoStudents y1&lt;/TD&gt;&lt;TD&gt;CumStudents y1&lt;/TD&gt;&lt;TD&gt;NoStudents y2&lt;/TD&gt;&lt;TD&gt;CumStudents y2&lt;/TD&gt;&lt;TD&gt;NoStudents y3&lt;/TD&gt;&lt;TD&gt;CumStudents y3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 16:20:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1962637#M42958</guid>
      <dc:creator>BI_diva</dc:creator>
      <dc:date>2021-07-16T16:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Cumulative distinctcount incorrect on blank rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963014#M42982</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var LastDurationVisible = MAX( MyTable[Duration] )
return
	CALCULATE(
		SUM( MyTable[NoStudents] ),
		MyTable[Duration] &amp;lt;= LastDurationVisible
	)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 21:15:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963014#M42982</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-16T21:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Cumulative distinctcount incorrect on blank rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963035#M42987</link>
      <description>&lt;P&gt;Hi Daxer, thank you for your suggested answer. I have just given it a try, but unfortunately the result in the table is still the same.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 21:27:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963035#M42987</guid>
      <dc:creator>BI_diva</dc:creator>
      <dc:date>2021-07-16T21:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Cumulative distinctcount incorrect on blank rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963044#M42989</link>
      <description>&lt;P&gt;You have to show more than what you have. Certainly, my formula is totally correct for the table shown and I can&amp;nbsp; totally prove it. If it does not work for you, it means you've got something in there that is different than what you've shown.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 21:36:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963044#M42989</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-16T21:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Cumulative distinctcount incorrect on blank rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963491#M43003</link>
      <description>&lt;P&gt;Hi Daxer, here is a link to the .pbix file:&amp;nbsp;&lt;A title="Pbix file cumulative 20210717" href="https://1drv.ms/u/s!As7R5dcyGWRKgjaQk8A-9fWvnO3W?e=ilibVn" target="_blank" rel="noopener"&gt;https://1drv.ms/u/s!As7R5dcyGWRKgjaQk8A-9fWvnO3W?e=ilibVn&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 11:06:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963491#M43003</guid>
      <dc:creator>BI_diva</dc:creator>
      <dc:date>2021-07-17T11:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Cumulative distinctcount incorrect on blank rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963582#M43016</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="314004" data-lia-user-login="BI_diva" class="lia-mention lia-mention-user"&gt;BI_diva&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just as I thought. You can ditch this model right away. It's simply wrong.&lt;STRONG&gt; Totally wrong&lt;/STRONG&gt;. In this model it's not possible to do what you want (or at least it would require such complex code that it would be totally unmaintainable and the code couldn't be understood by mere mortals; compare this to the code I gave you assuming the model is correct). The reasons are very technical but it all boils down to one thing: &lt;STRONG&gt;the dreaded auto-exists problem&lt;/STRONG&gt;. This is too technical so I'm not going to enlarge upon this. The solution to this is to create a good model that follows Best Practices set out for PBI (&lt;A href="https://docs.microsoft.com/en-us/power-bi/guidance/star-schema" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/power-bi/guidance/star-schema&lt;/A&gt;).&amp;nbsp;You just have to create a good star-schema, in a word, and pay good attention to how you structure it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll tell you quickly why it's not possible to do what you want. In your fact table not all combinations of attributes are present. So, you put an attribute on your rows---Duration that comes straight from your fact table and by doing this you shoot yourself in the foot immediately because never ever should you place columns from a fact table on the canvas apart from the one case when you troubleshoot issues--- and then you try to intersect this with what you put on columns (Schoolyear). Now, the blanks in your matrix are for combinations of Duration and Schoolyear in the fact table that do not exist. And because you sourced Duration from the fact table, a cell with a blank in it CANNOT see what the current Duration is. Because there is no duration for this combination in the fact table. And because there is no combination like this, the DAX code cannot even know what Duration the row in the matrix is looking at, hence you can't write a measure that would give you a correct cummulative. This is the short story. If you had proper dimensions, you'd write what I gave you (easy formula) and be done with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Remember, you should &lt;STRONG&gt;never&lt;/STRONG&gt; slice and dice by columns in your fact table. &lt;STRONG&gt;Always&lt;/STRONG&gt; via dimensions. This will save you a lot of grief and pulling your hair out.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 15:11:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Cumulative-distinctcount-incorrect-on-blank-rows/m-p/1963582#M43016</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-07-17T15:11:18Z</dc:date>
    </item>
  </channel>
</rss>

