<?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 | Count consecutive days of absence in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3385665#M127579</link>
    <description>&lt;P&gt;Thanks Mate,&lt;/P&gt;&lt;P&gt;I'm out of Questions now &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;/Nicolai&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 15:29:28 GMT</pubDate>
    <dc:creator>NicolaiW</dc:creator>
    <dc:date>2023-08-17T15:29:28Z</dc:date>
    <item>
      <title>DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3380253#M127341</link>
      <description>&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;Here is a challenge for you. I hope you can help me out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this dataset with employees registered working days. I want to create a visualization consisting of the employee, and a measure of the number of periods(&amp;gt;1day) of absence. So if an employee has one day of absence it should not be calculated in the measure, but only if they have periods of abcense that are more than one day. I want to count how many of these periods each employee has had. see picuture below for more explanation.&lt;/P&gt;&lt;P&gt;Keep in mind, that there will be several employees checking in the same day. So there will be more rows with the same date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking forward to see how you solve this. Good luck! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;/Nicolai&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 07:47:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3380253#M127341</guid>
      <dc:creator>NicolaiW</dc:creator>
      <dc:date>2023-08-15T07:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3380559#M127355</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="603068" data-lia-user-login="NicolaiW" class="lia-mention lia-mention-user"&gt;NicolaiW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I particularly like this method, which labels each contiguous period of absence. Each period is labelled by taking the difference between the date itself and the "rank" of the date among dates of absence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the measure, and PBIX attached.&lt;/P&gt;
&lt;P&gt;Note that (blank) rather than zero is returned if there are no periods of absence. This could be adjusted if needed.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Absence Periods = 
VAR Threshold =
    2
-- Combinations of Date/Employee for absence days
VAR AbsenceDays =
    CALCULATETABLE (
        SUMMARIZE ( Data, Data[Date], Data[Employee ID] ),
        Data[Day of Absence] = "Yes"
    )
-- Add @PeriodID which uniqely identifies each contiguous absence period per employee
VAR AddPeriodID =
	ADDCOLUMNS (
		AbsenceDays,
		"@PeriodID",
		VAR DateRank =
			RANK ( Dense, AbsenceDays, ORDERBY ( Data[Date], ASC ), Default, PARTITIONBY ( Data[Employee ID] ) )
		VAR Result =
			DateRank - Data[Date]
		RETURN
			Result
	)
-- @DaysPerPeriod is the # days of absence in each period per employee
VAR DaysPerPeriod =
	GROUPBY (
		AddPeriodID,
		[@PeriodID],
		Data[Employee ID],
		"@DaysPerPeriod", SUMX ( CURRENTGROUP(), 1 )
	)
-- Filter to absence periods &amp;gt;= Threshold
VAR FilterThreshold =
	FILTER (
		DaysPerPeriod,
		[@DaysPerPeriod] &amp;gt;= Threshold
	)
-- Count the resulting absence periods    
VAR Result =
    COUNTROWS ( FilterThreshold )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 12:16:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3380559#M127355</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-08-15T12:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3381233#M127384</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Awesome coding!&lt;BR /&gt;Howerver the DAX code you made, doesn't work with weekends. So if an employee has a period of absence of a month, it will be registered as 4 periods because of the 3 weekends. Could you perhaps come up with a solution for this? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;/Nicolai&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 19:46:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3381233#M127384</guid>
      <dc:creator>NicolaiW</dc:creator>
      <dc:date>2023-08-15T19:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3382757#M127466</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="603068" data-lia-user-login="NicolaiW" class="lia-mention lia-mention-user"&gt;NicolaiW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure thing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To handle that particular issue (and anything involving more complexity with dates) I recommend creating a 'Date' table that includes columns&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;"Is Workday"&lt;/STRONG&gt;: Boolean indicating whether a given date is a workday (Mon-Fri)&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt; "Workday Index":&lt;/STRONG&gt; An index which increments by one on each workday, but is blank on weekends.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In my updated PBIX this looks like this:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then to handle weekends by effectively ignoring them, rewrite the measure as follows:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Absence Periods Ignoring Weekends = 
VAR Threshold =
    2
-- Combinations of Date/Employee for absence days
VAR AbsenceDays =
    CALCULATETABLE (
        SUMMARIZE ( Data, 'Date'[Workday Index], Data[Employee ID] ),
        Data[Day of Absence] = "Yes",
        'Date'[Is Workday] -- equivalent to 'Date'[Is Workday] = TRUE
    )
-- Add @PeriodID which uniqely identifies each contiguous absence period per employee
VAR AddPeriodID =
	ADDCOLUMNS (
		AbsenceDays,
		"@PeriodID",
		VAR DateRank =
			RANK ( DENSE, AbsenceDays, ORDERBY ( 'Date'[Workday Index], ASC ), DEFAULT, PARTITIONBY ( Data[Employee ID] ) )
		VAR Result =
			DateRank - 'Date'[Workday Index]
		RETURN
			Result
	)
-- @DaysPerPeriod is the # days of absence in each period per employee
VAR DaysPerPeriod =
	GROUPBY (
		AddPeriodID,
		[@PeriodID],
		Data[Employee ID],
		"@DaysPerPeriod", SUMX ( CURRENTGROUP(), 1 )
	)
-- Filter to absence periods &amp;gt;= Threshold
VAR FilterThreshold =
	FILTER (
		DaysPerPeriod,
		[@DaysPerPeriod] &amp;gt;= Threshold
	)
-- Count the resulting absence periods    
VAR Result =
    COUNTROWS ( FilterThreshold )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;I added Employee 4 who was absent for every Mon-Fri in January. Combined with the existing data, the results look like below.&lt;/P&gt;
&lt;P&gt;You will note that:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Employee 4 indeed has 1 absence ignoring weekends.&lt;/LI&gt;
&lt;LI&gt;Employee 2 now has only 1 absence. This is because the new measure ignores the absence on Sat 7-Jan, so that absence is only 1 workday long and not counted.&lt;/LI&gt;
&lt;LI&gt;Employee 1 now has no absences. This is because the original absence was Sat 28-Jan to Mon 30-Jan, and is now only 1 workday long and not counted.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;Question:&lt;/STRONG&gt; Do weekend absences still need to be taken into account in any way, for the purpose of determining the length of an absence period, or can they be safely ignored in practice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We may need to rewrite the measure if so.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 12:47:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3382757#M127466</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-08-16T12:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3383394#M127479</link>
      <description>&lt;P&gt;Hi Owen,&lt;BR /&gt;Awesome Work mate! i recon we can ignore the weekends as people rarely work these&amp;nbsp; days anyway.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;A last small (hopefully) challenge for you. We also want to calculate the average length of these absence periods for each worker. Could you help me out with this as well?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks beforehand&lt;BR /&gt;/Nicolai&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 18:07:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3383394#M127479</guid>
      <dc:creator>NicolaiW</dc:creator>
      <dc:date>2023-08-16T18:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3384321#M127508</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="603068" data-lia-user-login="NicolaiW" class="lia-mention lia-mention-user"&gt;NicolaiW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi again Nicolai,&lt;/P&gt;
&lt;P&gt;No worries &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For Average Days per Absence, I would suggest a measure like this (updated PBIX attached with additional made-up data).&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average Days per Absence = 
VAR Threshold =
    2
-- Combinations of Date/Employee for absence days
VAR AbsenceDays =
    CALCULATETABLE (
        SUMMARIZE ( Data, 'Date'[Workday Index], Data[Employee ID] ),
        Data[Day of Absence] = "Yes",
        'Date'[Is Workday] -- equivalent to 'Date'[Is Workday] = TRUE
    )
-- Add @PeriodID which uniqely identifies each contiguous absence period per employee
VAR AddPeriodID =
	ADDCOLUMNS (
		AbsenceDays,
		"@PeriodID",
		VAR DateRank =
			RANK ( DENSE, AbsenceDays, ORDERBY ( 'Date'[Workday Index], ASC ), DEFAULT, PARTITIONBY ( Data[Employee ID] ) )
		VAR Result =
			DateRank - 'Date'[Workday Index]
		RETURN
			Result
	)
-- @DaysPerPeriod is the # days of absence in each period per employee
VAR DaysPerPeriod =
	GROUPBY (
		AddPeriodID,
		[@PeriodID],
		Data[Employee ID],
		"@DaysPerPeriod", SUMX ( CURRENTGROUP(), 1 )
	)
-- Filter to absence periods &amp;gt;= Threshold
VAR FilterThreshold =
	FILTER (
		DaysPerPeriod,
		[@DaysPerPeriod] &amp;gt;= Threshold
	)
-- Count the resulting absence periods    
VAR Result =
    AVERAGEX (
        FilterThreshold,
        [@DaysPerPeriod]
    )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;Hope that works for you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 05:37:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3384321#M127508</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-08-17T05:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3385665#M127579</link>
      <description>&lt;P&gt;Thanks Mate,&lt;/P&gt;&lt;P&gt;I'm out of Questions now &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;/Nicolai&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 15:29:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/3385665#M127579</guid>
      <dc:creator>NicolaiW</dc:creator>
      <dc:date>2023-08-17T15:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4626119#M177085</link>
      <description>&lt;P&gt;Hello, stumbled across this for my similar situation.&amp;nbsp;&lt;BR /&gt;This works but the issue i have is that i want to show Absences by Month. The above would count an abense which spans over a month barrier as 2 different absences.&amp;nbsp;&lt;BR /&gt;How would i get it to only count 1 absence, ideally shown in the month the absence started.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 15:22:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4626119#M177085</guid>
      <dc:creator>ElliotCartlidge</dc:creator>
      <dc:date>2025-03-26T15:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4626695#M177115</link>
      <description>&lt;P&gt;Hi there&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="417862" data-lia-user-login="ElliotCartlidge" class="lia-mention lia-mention-user"&gt;ElliotCartlidge&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here's one suggestion (updated PBIX attached).&lt;/P&gt;
&lt;P&gt;Create &lt;STRONG&gt;# Absence Periods by Start Date&lt;/STRONG&gt; by modifying &lt;STRONG&gt;# Absence Periods&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;The main updates are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Expand the range of dates to determine whether periods of absence begain during the filtered date range, and whether they meet the threshold (after the filtered date range (&lt;STRONG&gt;MinDateAdj&lt;/STRONG&gt; and &lt;STRONG&gt;MaxDateAdj&lt;/STRONG&gt;).&lt;/LI&gt;
&lt;LI&gt;In the &lt;STRONG&gt;DaysPerPeriod&lt;/STRONG&gt; variable, a "&lt;STRONG&gt;@PeriodStart&lt;/STRONG&gt;" column is added containing the first date of the absence period. In the &lt;STRONG&gt;EnforceDateFilter&lt;/STRONG&gt; variable, this is then filtered to absence periods starting in the filtered date range.&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI-CODE lang="markup"&gt;# Absence Periods by Start Date = 
VAR Threshold =
    2
-- Period will be expanded by looking back one day and forward Threshold - 1 days
-- to determine whether qualifying absence periods begain in filtered date range
VAR MinDateAdj =
    MIN ( 'Date'[Date] ) - 1
VAR MaxDateAdj =
    MAX ( 'Date'[Date] ) + Threshold - 1

-- Combinations of Date/Employee for absence days
VAR AbsenceDays =
    CALCULATETABLE (
        SUMMARIZE ( Data, 'Date'[Date], Data[Employee ID] ),
        Data[Day of Absence] = "Yes",
        DATESBETWEEN ( 'Date'[Date], MinDateAdj, MaxDateAdj )
    )
-- Add @PeriodID which uniqely identifies each contiguous absence period per employee
VAR AddPeriodID =
	ADDCOLUMNS (
		AbsenceDays,
		"@PeriodID",
		VAR DateRank =
			RANK ( DENSE, AbsenceDays, ORDERBY ( 'Date'[Date], ASC ), DEFAULT, PARTITIONBY ( Data[Employee ID] ) )
		VAR Result =
			DateRank - 'Date'[Date]
		RETURN
			Result
	)
-- @DaysPerPeriod is the # days of absence in each period per employee
VAR DaysPerPeriod =
	GROUPBY (
		AddPeriodID,
		[@PeriodID],
		Data[Employee ID],
		"@DaysPerPeriod", SUMX ( CURRENTGROUP(), 1 ),
        "@PeriodStart", MINX ( CURRENTGROUP (), 'Date'[Date] )
	)
-- Use a join to include only  absences beginning intside filtered date range
VAR EnforceDateFilter =
	NATURALINNERJOIN ( DaysPerPeriod, SELECTCOLUMNS ( VALUES ( 'Date'[Date] ), "@PeriodStart", 'Date'[Date] + 0  ) )

-- Filter to absence periods &amp;gt;= Threshold that begin during period
VAR FilterThreshold =
	FILTER (
		EnforceDateFilter,
        [@DaysPerPeriod] &amp;gt;= Threshold
    )
    
-- Count the resulting absence periods    
VAR Result =
    COUNTROWS ( FilterThreshold )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;I made up some extra data for testing. For now I have left Threshold = 2 but this can be changed.&lt;/P&gt;
&lt;P&gt;Sample visual:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;This measure is likely ripe for optimisation.&lt;/P&gt;
&lt;P&gt;It would also be possible to process the data before loading so that it is loaded as three columns:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;Employee ID | Absence Start Date | Absence Duration&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This would greatly simplify the DAX.&lt;/P&gt;
&lt;P&gt;I will revisit when I have a chance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this the sort of thing you were looking for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 01:38:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4626695#M177115</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-03-27T01:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4626785#M177119</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="417862" data-lia-user-login="ElliotCartlidge" class="lia-mention lia-mention-user"&gt;ElliotCartlidge&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&amp;nbsp;Here is an example of how you could transform the Absence table to simplify the measure (PBIX attached).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Restructure the Absence table, with one row per contiguous Absence per Employee.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;2. Relate Absence[Absence Start] to 'Date'[Date].&lt;/P&gt;
&lt;P&gt;3. Create this measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Absence Periods by Start Date v2 = 
VAR Threshold =
    2
VAR Result =
    CALCULATE (
        COUNTROWS ( AbsenceRestructure ),
        KEEPFILTERS ( AbsenceRestructure[Absence Duration] &amp;gt;= Threshold )
    )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;Note that you could preserve the original fact table and add this as an additional form of the fact table for specific measures, depending on the reporting requirements.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 04:43:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4626785#M177119</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-03-27T04:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4627068#M177134</link>
      <description>&lt;P&gt;Hi Owen,&lt;/P&gt;&lt;P&gt;This works great, the only issue i see is that its correctly not counting weekends as absences, however if an Absence goes over a weekend into the next week, this will be counted as 2 seperate occurances, instead of 1. We'd ideally like to count this as 1 occurance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 08:43:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4627068#M177134</guid>
      <dc:creator>ElliotCartlidge</dc:creator>
      <dc:date>2025-03-27T08:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4631015#M177299</link>
      <description>&lt;P&gt;Just clarifying the issue with an example:&lt;/P&gt;
&lt;P&gt;If an absence goes from Thursday to the following Tuesday it is currently counted as two absences but should be counted as one?&lt;/P&gt;</description>
      <pubDate>Sun, 30 Mar 2025 23:00:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4631015#M177299</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-03-30T23:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4631175#M177305</link>
      <description>&lt;P&gt;Correct, weekends shouldn't be able to seperate an absence.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 07:12:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4631175#M177305</guid>
      <dc:creator>ElliotCartlidge</dc:creator>
      <dc:date>2025-03-31T07:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4632182#M177354</link>
      <description>&lt;P&gt;Great thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;I think the "easiest" method is to rewrite the measure using Workday Index rather than Date.&lt;/P&gt;
&lt;P&gt;I haven't fully tested this but this is what I'm thinking:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Absence Periods by Start Date (ignore weekends) = 
VAR Threshold =
    2
-- Period will be expanded by looking back one day and forward Threshold - 1 days
-- to determine whether qualifying absence periods begain in filtered date range
VAR MinDateAdj =
    MIN ( 'Date'[Workday Index] ) - 1
VAR MaxDateAdj =
    MAX ( 'Date'[Workday Index] ) + Threshold - 1

-- Combinations of Date/Employee for absence days
VAR AbsenceDays =
    CALCULATETABLE (
        SUMMARIZE ( Absence, 'Date'[Workday Index], Absence[Employee ID] ),
        Absence[Day of Absence] = "Yes",
        -- =============================================
        -- *** Updated conditions based on Workday Index
        'Date'[Workday Index] &amp;gt;= MinDateAdj,
        'Date'[Workday Index] &amp;lt;= MaxDateAdj,
		NOT ISBLANK ( 'Date'[Workday Index] ),
        REMOVEFILTERS ( 'Date' )
        -- =============================================
    )
-- Add @PeriodID which uniqely identifies each contiguous absence period per employee
VAR AddPeriodID =
	ADDCOLUMNS (
		AbsenceDays,
		"@PeriodID",
		VAR DateRank =
			RANK ( DENSE, AbsenceDays, ORDERBY ( 'Date'[Workday Index], ASC ), DEFAULT, PARTITIONBY ( Absence[Employee ID] ) )
		VAR Result =
			DateRank - 'Date'[Workday Index]
		RETURN
			Result
	)
-- @DaysPerPeriod is the # days of absence in each period per employee
VAR DaysPerPeriod =
	GROUPBY (
		AddPeriodID,
		[@PeriodID],
		Absence[Employee ID],
		"@DaysPerPeriod", SUMX ( CURRENTGROUP(), 1 ),
        "@PeriodStart", MINX ( CURRENTGROUP (), 'Date'[Workday Index] )
	)
-- Use a join to include only  absences beginning intside filtered date range
VAR EnforceDateFilter =
	NATURALINNERJOIN ( DaysPerPeriod, SELECTCOLUMNS ( VALUES ( 'Date'[Workday Index] ), "@PeriodStart", 'Date'[Workday Index] + 0  ) )

-- Filter to absence periods &amp;gt;= Threshold that begin during period
VAR FilterThreshold =
	FILTER (
		EnforceDateFilter,
        [@DaysPerPeriod] &amp;gt;= Threshold
    )
    
-- Count the resulting absence periods    
VAR Result =
    COUNTROWS ( FilterThreshold )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;It looks correct following a quick check, but there might be some edge cases to handle.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 21:37:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4632182#M177354</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-03-31T21:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4634590#M177417</link>
      <description>&lt;P&gt;Hi Owen,&lt;/P&gt;&lt;P&gt;Something that differs from the original problem is that a single day for me is classed as an absence. So as per your data set, employee 2 would have 3 absences in Jan. Could you adjust so it counts that?&lt;BR /&gt;&lt;BR /&gt;Also quick note, simply copy pasting this in didn't work, i had to adjust the "REMOVEFILTERS ('Date')" part in this to a specfic date column.&lt;/P&gt;&lt;PRE&gt;VAR AbsenceDays =
    CALCULATETABLE (
        SUMMARIZE ( Absence, 'Date'[Workday Index], Absence[Employee ID] ),
        Absence[Day of Absence] = "Yes",
        -- =============================================
        -- *** Updated conditions based on Workday Index
        'Date'[Workday Index] &amp;gt;= MinDateAdj,
        'Date'[Workday Index] &amp;lt;= MaxDateAdj,
		NOT ISBLANK ( 'Date'[Workday Index] ),
        REMOVEFILTERS ( 'Date' )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really appreciate the help with this!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 08:28:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4634590#M177417</guid>
      <dc:creator>ElliotCartlidge</dc:creator>
      <dc:date>2025-04-02T08:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: DAX | Count consecutive days of absence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4635574#M177466</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="417862" data-lia-user-login="ElliotCartlidge" class="lia-mention lia-mention-user"&gt;ElliotCartlidge&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To count all absences of a single day or more, change the Threshold variable to 1:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR Threshold =
    1&lt;/LI-CODE&gt;
&lt;P&gt;On your second point, it must be something specific to your model. Do you have a similar setup with the 'Date' table related to the Absence table? But if you have it working already that's fine &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 18:19:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Count-consecutive-days-of-absence/m-p/4635574#M177466</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-04-02T18:19:54Z</dc:date>
    </item>
  </channel>
</rss>

