<?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: Count first instance in date range in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-first-instance-in-date-range/m-p/3472336#M132599</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="294792" data-lia-user-login="EWBWEBB" class="lia-mention lia-mention-user"&gt;EWBWEBB&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, here are my steps you can follow as a solution.&lt;/P&gt;
&lt;P&gt;(1) My test data is the same as yours.&lt;/P&gt;
&lt;P&gt;(2) We can create measures.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Period = 
var _min= CALCULATE(MIN('Table'[DateKey]),FILTER(ALLSELECTED('Table'),'Table'[ServiceLength_Months]=24 &amp;amp;&amp;amp; 'Table'[ID]=MAX('Table'[ID])))
var _Period=CALCULATE(MAX('Table (2)'[Period]),FILTER(ALLSELECTED('Table (2)'),'Table (2)'[DateKey]=_min))
return _Period&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Count = 
var _table=SUMMARIZE(ALL('Table'),'Table'[ID],"per",[Period])
return COUNTROWS(FILTER(_table,[per] = MAX('Table (2)'[Period])))&lt;/LI-CODE&gt;
&lt;P&gt;(3) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/STRONG&gt;) with&amp;nbsp;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;pbix file.&amp;nbsp;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2023 03:14:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-10-12T03:14:47Z</dc:date>
    <item>
      <title>Count first instance in date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-first-instance-in-date-range/m-p/3467488#M132352</link>
      <description>&lt;P&gt;I am trying to count all those that have reached 24 months milestone in a given date range.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data has a row of data per person, per day with a column that indicates months service. So someone will have 24 months service for approximately 30 (give or take) rows. I would like to count just the first time the number 24 appears so I can show, for example, how many people reached this milestone in a given time period. Each period I have is roughly 28 days long so someones 30ish rows of data will likey span more than one period - I want to count them the first period their 24 appears.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a large data set so a calculated column is to slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've gone DAX blind this afternoon so can't see wood for the trees.&lt;BR /&gt;&lt;BR /&gt;This is my current attempt (which I know is off) but highlights the route I'm trying to take - I think.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#CurrentCustomerAchieving24Months = 

VAR First24 = 
    CALCULATE(
        MIN('Data'[DateKey]),
        FILTER('Data', 'Data'[ServiceLength_Months] = 24 )
    )
VAR Counter = 
CALCULATE(
    COUNTROWS('Data'),
    FILTER(
        'Data', 'Data'[ServiceLength_Months] = 24 )
    &amp;amp;&amp;amp; 'Data'[DateKey] = First24 )
        
RETURN

Counter&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example Data in the attached.&lt;/P&gt;&lt;P&gt;In the attached I would want to be able to count person 12345 in Period 1 and Person 67891 in Period 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should be a link to the very simplified example&lt;/P&gt;&lt;P&gt;&lt;A href="https://we.tl/t-Fse9l24Jn9" target="_blank"&gt;https://we.tl/t-Fse9l24Jn9&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 19:54:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-first-instance-in-date-range/m-p/3467488#M132352</guid>
      <dc:creator>EWBWEBB</dc:creator>
      <dc:date>2023-10-09T19:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Count first instance in date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-first-instance-in-date-range/m-p/3472336#M132599</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="294792" data-lia-user-login="EWBWEBB" class="lia-mention lia-mention-user"&gt;EWBWEBB&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, here are my steps you can follow as a solution.&lt;/P&gt;
&lt;P&gt;(1) My test data is the same as yours.&lt;/P&gt;
&lt;P&gt;(2) We can create measures.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Period = 
var _min= CALCULATE(MIN('Table'[DateKey]),FILTER(ALLSELECTED('Table'),'Table'[ServiceLength_Months]=24 &amp;amp;&amp;amp; 'Table'[ID]=MAX('Table'[ID])))
var _Period=CALCULATE(MAX('Table (2)'[Period]),FILTER(ALLSELECTED('Table (2)'),'Table (2)'[DateKey]=_min))
return _Period&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Count = 
var _table=SUMMARIZE(ALL('Table'),'Table'[ID],"per",[Period])
return COUNTROWS(FILTER(_table,[per] = MAX('Table (2)'[Period])))&lt;/LI-CODE&gt;
&lt;P&gt;(3) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/STRONG&gt;) with&amp;nbsp;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;pbix file.&amp;nbsp;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 03:14:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-first-instance-in-date-range/m-p/3472336#M132599</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-12T03:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count first instance in date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-first-instance-in-date-range/m-p/3478405#M132943</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked perfectly thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a reason that you did this as 2 seperate measures rather than using a Variable for the 'Period' mesaure, or just preference?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just help inform my thinking next time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 09:36:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-first-instance-in-date-range/m-p/3478405#M132943</guid>
      <dc:creator>EWBWEBB</dc:creator>
      <dc:date>2023-10-16T09:36:40Z</dc:date>
    </item>
  </channel>
</rss>

