<?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 Count people based on condition across multiple dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-people-based-on-condition-across-multiple-dates/m-p/4586137#M175697</link>
    <description>&lt;P&gt;Hi There&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to count the number of people who became long term sick in a period and remained sick at the end of the period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We work in 4 week period not months so I have to use a Period column for MIN/MAX date ranges.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to calcualte is:&lt;BR /&gt;The count of people (by PersonNumber) that reached 28 consecutive days sick within a period and remained sick at the end of the period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached a sample file for one individual and the anticipated behaviour would be:&lt;BR /&gt;Period 1 - not counted&lt;BR /&gt;Period 2 - counted&lt;BR /&gt;Period 3 not counted&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm only interested in the Paycode "Sick" so could filter the table by that initially.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Reasoning:&lt;/P&gt;&lt;P&gt;Period one - consecutive days sick do not reach 28&lt;BR /&gt;Period two - On the first day of the period (29/01/24) consecutive sick days was less than 28, on 05/02/24 they reached 28 consecutive days sick, on the last day of the period (25/02/24) they remained sick.&lt;BR /&gt;Period three - started the period with more than 28 conseuctive days sick, was also not sick on the last day of the period (31/03/24).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There will be multiple people in the list so I want something akin to a partition by SQL function I think.&lt;/P&gt;&lt;P&gt;I would like to do this using a measure not a calculated column as the actual data set is quite large.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="Sample file for one individual - in reality this would be for multiple people." href="https://we.tl/t-qdhbqxpyIu" target="_self"&gt;Sample File&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2025 14:22:25 GMT</pubDate>
    <dc:creator>EWBWEBB</dc:creator>
    <dc:date>2025-02-26T14:22:25Z</dc:date>
    <item>
      <title>Count people based on condition across multiple dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-people-based-on-condition-across-multiple-dates/m-p/4586137#M175697</link>
      <description>&lt;P&gt;Hi There&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to count the number of people who became long term sick in a period and remained sick at the end of the period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We work in 4 week period not months so I have to use a Period column for MIN/MAX date ranges.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to calcualte is:&lt;BR /&gt;The count of people (by PersonNumber) that reached 28 consecutive days sick within a period and remained sick at the end of the period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached a sample file for one individual and the anticipated behaviour would be:&lt;BR /&gt;Period 1 - not counted&lt;BR /&gt;Period 2 - counted&lt;BR /&gt;Period 3 not counted&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm only interested in the Paycode "Sick" so could filter the table by that initially.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Reasoning:&lt;/P&gt;&lt;P&gt;Period one - consecutive days sick do not reach 28&lt;BR /&gt;Period two - On the first day of the period (29/01/24) consecutive sick days was less than 28, on 05/02/24 they reached 28 consecutive days sick, on the last day of the period (25/02/24) they remained sick.&lt;BR /&gt;Period three - started the period with more than 28 conseuctive days sick, was also not sick on the last day of the period (31/03/24).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There will be multiple people in the list so I want something akin to a partition by SQL function I think.&lt;/P&gt;&lt;P&gt;I would like to do this using a measure not a calculated column as the actual data set is quite large.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="Sample file for one individual - in reality this would be for multiple people." href="https://we.tl/t-qdhbqxpyIu" target="_self"&gt;Sample File&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 14:22:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-people-based-on-condition-across-multiple-dates/m-p/4586137#M175697</guid>
      <dc:creator>EWBWEBB</dc:creator>
      <dc:date>2025-02-26T14:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count people based on condition across multiple dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-people-based-on-condition-across-multiple-dates/m-p/4587081#M175729</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;Please crate a measure as follows:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CountLongTermSick = 
SUMX(
    VALUES('Table'[Period]),
    VAR _sickdays = CALCULATE(COUNTROWS('Table'), FILTER(ALLEXCEPT('Table', 'Table'[Period], 'Table'[PersonNumber]), 'Table'[Paycode] = "Sick"))
    VAR _maxdate = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Period], 'Table'[PersonNumber]))
    VAR _SickAtEndOfPeriod = IF(CALCULATE(MAX('Table'[Paycode]), FILTER(ALLEXCEPT('Table', 'Table'[Period], 'Table'[PersonNumber]), 'Table'[Date] = _maxdate)) = "Sick", 1, 0)
    VAR _count = IF(_sickdays &amp;gt;= 28 &amp;amp;&amp;amp; _SickAtEndOfPeriod = 1, CALCULATE(DISTINCTCOUNT('Table'[PersonNumber]), ALLEXCEPT('Table', 'Table'[Period])), 0)
    RETURN _count
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Zhu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;I&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/I&gt;, then please consider&amp;nbsp;&lt;I&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/I&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 04:02:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-people-based-on-condition-across-multiple-dates/m-p/4587081#M175729</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-27T04:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Count people based on condition across multiple dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-people-based-on-condition-across-multiple-dates/m-p/4588572#M175787</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;- thank you so much.&lt;BR /&gt;I understand the log there which is really helpful however I've got stuck and should have mentioned this in the original post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dates and periods are held in a Dim_Date table joined to the Fact_AttendanceTable on date as one to many.&lt;BR /&gt;&lt;BR /&gt;The Dim_Date table is a row per date with coresponding Period&lt;BR /&gt;Fact attendance is a row per person per day - as in the attached file.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 18:30:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-people-based-on-condition-across-multiple-dates/m-p/4588572#M175787</guid>
      <dc:creator>EWBWEBB</dc:creator>
      <dc:date>2025-02-27T18:30:58Z</dc:date>
    </item>
  </channel>
</rss>

