<?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: How to calculate the number of days of absence per month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4666999#M178761</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="401421" data-lia-user-login="Boeboey" class="lia-mention lia-mention-user"&gt;Boeboey&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a Date table if you don't already have one. This table should include all the dates for the period you are analyzing.&lt;/P&gt;
&lt;P&gt;Create a measure to calculate the total number of days of absence per month.&lt;/P&gt;
&lt;P&gt;DAX&lt;BR /&gt;TotalAbsenceDays = &lt;BR /&gt;VAR StartDate = MIN('AbsenceTable'[absence start date])&lt;BR /&gt;VAR EndDate = MAX('AbsenceTable'[absence end date])&lt;BR /&gt;VAR DateRange = &lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;CALENDAR(StartDate, EndDate),&lt;BR /&gt;"YearMonth", FORMAT([Date], "YYYY-MM")&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;SUMX(&lt;BR /&gt;DateRange,&lt;BR /&gt;VAR CurrentYearMonth = [YearMonth]&lt;BR /&gt;VAR AbsenceDays = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('AbsenceTable'),&lt;BR /&gt;FILTER(&lt;BR /&gt;'AbsenceTable',&lt;BR /&gt;'AbsenceTable'[absence start date] &amp;lt;= [Date] &amp;amp;&amp;amp;&lt;BR /&gt;'AbsenceTable'[absence end date] &amp;gt;= [Date]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN AbsenceDays&lt;BR /&gt;)&lt;/P&gt;</description>
    <pubDate>Thu, 24 Apr 2025 14:14:50 GMT</pubDate>
    <dc:creator>bhanu_gautam</dc:creator>
    <dc:date>2025-04-24T14:14:50Z</dc:date>
    <item>
      <title>How to calculate the number of days of absence per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4666896#M178756</link>
      <description>&lt;P&gt;I have an absence table with the colums [absence start date] and [absence end date].&lt;BR /&gt;I would like to calculate the total number of days of absence per month&lt;BR /&gt;&lt;BR /&gt;E.g.&lt;/P&gt;&lt;P&gt;absence 1 | start: 28-01-2025 | end: 03-02-2025 (4 days in January and 3 days in February)&lt;/P&gt;&lt;P&gt;absence 2 | start: 23-01-2025 | end: 26-01-2025 (4 days in January)&lt;/P&gt;&lt;P&gt;absence 3 | start: 01-02-2025 | end: 06-02-2025 (6 days in February)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;January: 8 days&lt;/P&gt;&lt;P&gt;February: 9 days&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to create such a measure (or a calculated column)?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 13:33:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4666896#M178756</guid>
      <dc:creator>Boeboey</dc:creator>
      <dc:date>2025-04-24T13:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the number of days of absence per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4666992#M178760</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. Create a Dates Table&lt;/STRONG&gt; (if you don’t already have one)&lt;/P&gt;&lt;P&gt;Dates =&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;CALENDAR ( MIN(Absences[absence start date]), MAX(Absences[absence end date]) ),&lt;BR /&gt;"Year", YEAR([Date]),&lt;BR /&gt;"Month", FORMAT([Date], "MMMM"),&lt;BR /&gt;"Month Year", FORMAT([Date], "MMM YYYY")&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H4&gt;2. &lt;STRONG&gt;Create a Bridge Table Between Dates and Absences&lt;/STRONG&gt;&lt;/H4&gt;&lt;P class=""&gt;You need a &lt;STRONG&gt;many-to-many relationship&lt;/STRONG&gt;, so we create a virtual table (via a measure) or a &lt;STRONG&gt;flattened version&lt;/STRONG&gt; via Power Query or DAX.&lt;/P&gt;&lt;P class=""&gt;But here's a dynamic DAX approach using a &lt;STRONG&gt;measure&lt;/STRONG&gt;:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Days of Absence =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;COUNTROWS (&lt;BR /&gt;FILTER (&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;VALUES ( Dates[Date] ),&lt;BR /&gt;"IsAbsent",&lt;BR /&gt;CALCULATE (&lt;BR /&gt;COUNTROWS ( Absences ),&lt;BR /&gt;FILTER (&lt;BR /&gt;Absences,&lt;BR /&gt;Dates[Date] &amp;gt;= Absences[absence start date]&lt;BR /&gt;&amp;amp;&amp;amp; Dates[Date] &amp;lt;= Absences[absence end date]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;[IsAbsent] &amp;gt; 0&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Another Alternative way in Power Query:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Power Query Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let&lt;BR /&gt;// 1. Load your Absences table&lt;BR /&gt;Source = Absences,&lt;/P&gt;&lt;P&gt;// 2. Add a Custom Column that generates a list of dates from start to end&lt;BR /&gt;AddDates = Table.AddColumn(Source, "DateList", each List.Dates([absence start date], Duration.Days([absence end date] - [absence start date]) + 1, #duration(1,0,0,0))),&lt;/P&gt;&lt;P&gt;// 3. Expand the DateList into rows&lt;BR /&gt;ExpandedDates = Table.ExpandListColumn(AddDates, "DateList"),&lt;/P&gt;&lt;P&gt;// 4. Add Year, Month, and Month-Year columns for grouping&lt;BR /&gt;AddYear = Table.AddColumn(ExpandedDates, "Year", each Date.Year([DateList])),&lt;BR /&gt;AddMonth = Table.AddColumn(AddYear, "Month", each Date.Month([DateList])),&lt;BR /&gt;AddMonthName = Table.AddColumn(AddMonth, "Month Name", each Date.ToText([DateList], "MMM yyyy")),&lt;/P&gt;&lt;P&gt;// 5. Group by Month-Year and count rows (days)&lt;BR /&gt;Grouped = Table.Group(AddMonthName, {"Month Name"}, {{"Days of Absence", each Table.RowCount(_), Int64.Type}}),&lt;/P&gt;&lt;P&gt;// 6. Optional: Sort by date for better visuals&lt;BR /&gt;AddSortDate = Table.AddColumn(Grouped, "SortDate", each Date.FromText("01 " &amp;amp; [Month Name])),&lt;BR /&gt;Sorted = Table.Sort(AddSortDate, {{"SortDate", Order.Ascending}}),&lt;BR /&gt;Final = Table.RemoveColumns(Sorted, {"SortDate"})&lt;BR /&gt;in&lt;BR /&gt;Final&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 14:12:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4666992#M178760</guid>
      <dc:creator>rosha_rosha</dc:creator>
      <dc:date>2025-04-24T14:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the number of days of absence per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4666999#M178761</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="401421" data-lia-user-login="Boeboey" class="lia-mention lia-mention-user"&gt;Boeboey&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a Date table if you don't already have one. This table should include all the dates for the period you are analyzing.&lt;/P&gt;
&lt;P&gt;Create a measure to calculate the total number of days of absence per month.&lt;/P&gt;
&lt;P&gt;DAX&lt;BR /&gt;TotalAbsenceDays = &lt;BR /&gt;VAR StartDate = MIN('AbsenceTable'[absence start date])&lt;BR /&gt;VAR EndDate = MAX('AbsenceTable'[absence end date])&lt;BR /&gt;VAR DateRange = &lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;CALENDAR(StartDate, EndDate),&lt;BR /&gt;"YearMonth", FORMAT([Date], "YYYY-MM")&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;SUMX(&lt;BR /&gt;DateRange,&lt;BR /&gt;VAR CurrentYearMonth = [YearMonth]&lt;BR /&gt;VAR AbsenceDays = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('AbsenceTable'),&lt;BR /&gt;FILTER(&lt;BR /&gt;'AbsenceTable',&lt;BR /&gt;'AbsenceTable'[absence start date] &amp;lt;= [Date] &amp;amp;&amp;amp;&lt;BR /&gt;'AbsenceTable'[absence end date] &amp;gt;= [Date]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN AbsenceDays&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 14:14:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4666999#M178761</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-04-24T14:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the number of days of absence per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4669922#M178866</link>
      <description>&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="401421" data-lia-user-login="Boeboey" class="lia-mention lia-mention-user"&gt;Boeboey&lt;/a&gt;,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Just following up to check if the solution shared by our Super User helped resolve your issue. If you're still facing difficulties or need further assistance, please let us know — we’re here to help!&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;If the response addressed your query, we kindly request you to mark it as &lt;SPAN&gt;Accepted Solution&lt;/SPAN&gt; and click &lt;SPAN&gt;Yes&lt;/SPAN&gt; if you found it helpful. This supports others in the community as well.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Best regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Prasanna Kumar&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 05:12:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4669922#M178866</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-04-28T05:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the number of days of absence per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4670231#M178886</link>
      <description>&lt;P&gt;Thanks for the quick answer!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 07:55:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-the-number-of-days-of-absence-per-month/m-p/4670231#M178886</guid>
      <dc:creator>Boeboey</dc:creator>
      <dc:date>2025-04-28T07:55:22Z</dc:date>
    </item>
  </channel>
</rss>

