<?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: Iterating over Measure calculations, counting current status of groups. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138099#M49094</link>
    <description>&lt;P&gt;It's fairly trivial to combine the measures you have into one by expanding [Flag] inside [Total] but I'm guessing you're looking for something cleaner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I propose the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;StatusCount =
VAR Summary =
    SUMMARIZE ( ALL ( Data ), Data[Applicant ID], "MaxDate", MAX ( Data[Date] ) )
RETURN
    CALCULATE (
        COUNTROWS ( Data ),
        TREATAS ( Summary, Data[Applicant ID], Data[Date] )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, we compute a Summary table to get the maximal date for each distinct applicant. Note that I've used ALL since, otherwise, we'd only get the rows corresponding to the current Application Status filter.&lt;/P&gt;
&lt;P&gt;Bearing this in mind, inside of COUNTROWS, Data is a subtable already filtered on Application Status but we wish to filter it further by only considering the most recent status.&lt;/P&gt;
&lt;P&gt;To do this, I use TREATAS to treat the [Applicant ID] and [MaxDate] columns of Summarize as the only set pairs allowable for Data[Applicant ID] and Data[Date].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This simple-looking measure hides quite a bit of subtlety. I recommend reading this article to get a better handle on this sort of pattern:&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 21:11:38 GMT</pubDate>
    <dc:creator>AlexisOlson</dc:creator>
    <dc:date>2021-10-15T21:11:38Z</dc:date>
    <item>
      <title>Iterating over Measure calculations, counting current status of groups.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138058#M49093</link>
      <description>&lt;P&gt;Hi, is there a better way of doing this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets say I have to identify the current application stage of candidates in our system. To do so, I'll first flag candidates with an IF-statement that evaluates 1 on their most current status (based on date and status name). However, the calculation is incomplete because the total does not sum correctly. Therefore, I add an additional step to iterate with SumX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, can I boil this into one tidy DAX calc rather than two? I've tried but haven't been successful. To be clear, I want an end table that lists ALL the status available, and sums the current status.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PBI file:&amp;nbsp;&lt;FONT color="#993300"&gt;&lt;A title="Example File" href="https://a.tmp.ninja/AJujxFok.pbix" target="_blank" rel="noopener"&gt;Example File&lt;/A&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 22:00:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138058#M49093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-15T22:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating over Measure calculations, counting current status of groups.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138099#M49094</link>
      <description>&lt;P&gt;It's fairly trivial to combine the measures you have into one by expanding [Flag] inside [Total] but I'm guessing you're looking for something cleaner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I propose the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;StatusCount =
VAR Summary =
    SUMMARIZE ( ALL ( Data ), Data[Applicant ID], "MaxDate", MAX ( Data[Date] ) )
RETURN
    CALCULATE (
        COUNTROWS ( Data ),
        TREATAS ( Summary, Data[Applicant ID], Data[Date] )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, we compute a Summary table to get the maximal date for each distinct applicant. Note that I've used ALL since, otherwise, we'd only get the rows corresponding to the current Application Status filter.&lt;/P&gt;
&lt;P&gt;Bearing this in mind, inside of COUNTROWS, Data is a subtable already filtered on Application Status but we wish to filter it further by only considering the most recent status.&lt;/P&gt;
&lt;P&gt;To do this, I use TREATAS to treat the [Applicant ID] and [MaxDate] columns of Summarize as the only set pairs allowable for Data[Applicant ID] and Data[Date].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This simple-looking measure hides quite a bit of subtlety. I recommend reading this article to get a better handle on this sort of pattern:&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 21:11:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138099#M49094</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-10-15T21:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating over Measure calculations, counting current status of groups.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138136#M49100</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;, thanks for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me clarify, how would we output a measure that displays all the available application status and a count of the current status of each application? So when I apply application status row context, the status without any "active" applications does not drop out.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 22:03:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138136#M49100</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-15T22:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating over Measure calculations, counting current status of groups.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138152#M49102</link>
      <description>&lt;P&gt;So your concern is that it returns a blank instead of zero for Screen?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could just add " + 0" to the end of the measure I suggested. More discussion of 0 vs blank here:&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/how-to-return-0-instead-of-blank-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/how-to-return-0-instead-of-blank-in-dax/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 22:43:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138152#M49102</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-10-15T22:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating over Measure calculations, counting current status of groups.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138155#M49104</link>
      <description>&lt;P&gt;Wow, I never thought of just adding 0 to the end.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 22:45:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Iterating-over-Measure-calculations-counting-current-status-of/m-p/2138155#M49104</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-15T22:45:56Z</dc:date>
    </item>
  </channel>
</rss>

