<?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: Calculating active employees in each month of a year using hire date and end date columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4638576#M177599</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to calculate the active employees if we have duplicate data in the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex: the table will have multiple rows for an empoyee when he has changed the department.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Darshan&lt;/P&gt;</description>
    <pubDate>Fri, 04 Apr 2025 15:44:47 GMT</pubDate>
    <dc:creator>DarshanKumar</dc:creator>
    <dc:date>2025-04-04T15:44:47Z</dc:date>
    <item>
      <title>Calculating active employees in each month of a year using hire date and end date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4243074#M167988</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an employee table with hire date and end date columns and a date table.&lt;/P&gt;&lt;P&gt;There is an active relation between Date[date] and Employee[end date] and an inactive relation between Date[date] and Employee[hire date].&lt;/P&gt;&lt;P&gt;The requirement is to show no of active employees in each month of the year in a column chart.&lt;/P&gt;&lt;P&gt;I have used the below DAX formula&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Active Employees =&lt;/SPAN&gt;&lt;/DIV&g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;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and got the below outcome which is wrong&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I have tried this Dax formula&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Head Count =&lt;/SPAN&gt; &lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;[No.of Resources]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt;= &lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and got below outcome&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;This is a bette outcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, the issue is this formula is not considering the hire date while calculating active resources.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example, if an employee has a start date as 10/04/24 and end date as 31/07/24, he should only be included in the active employees in April, May, June and July. he shouldn't be included for the months before april 2024.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this 2nd formula is including the above employee in every month till Jul 24.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me to modify the DAX to calculate active employees considering both hire date and end date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kartheek&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 15 Oct 2024 12:34:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4243074#M167988</guid>
      <dc:creator>KartheekJ</dc:creator>
      <dc:date>2024-10-15T12:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating active employees in each month of a year using hire date and end date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4243198#M167994</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="822049" data-lia-user-login="KartheekJ" class="lia-mention lia-mention-user"&gt;KartheekJ&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding this topic, the key to solving your headcount issue is to set your calendar (date) table as a disconnected table from your employee table, which contains information such as employee ID, joining date, and leaving date. Then, you can write a DAX formula like the one below, enabling you to calculate headcount at any point in time!&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Headcount =
SUMX (
    EmployeeFact,
    IF (
        EmployeeFact[Start] &amp;lt;= [SelectedDate]
            &amp;amp;&amp;amp; EmployeeFact[End] &amp;gt;= [SelectedDate],
        1,
        BLANK ()
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;Please refer to the article below if you’d like to explore this topic further.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/Dynamic-Headcount-Analysis-using-Dax/ba-p/4164529" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/Dynamic-Headcount-Analysis-using-Dax/ba-p/4164529&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 13:54:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4243198#M167994</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2024-10-15T13:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating active employees in each month of a year using hire date and end date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4243233#M167999</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="608865" data-lia-user-login="DataNinja777" class="lia-mention lia-mention-user"&gt;DataNinja777&lt;/a&gt;.&amp;nbsp; Thank you very much for the quick response.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 14:37:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4243233#M167999</guid>
      <dc:creator>KartheekJ</dc:creator>
      <dc:date>2024-10-15T14:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating active employees in each month of a year using hire date and end date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4638576#M177599</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to calculate the active employees if we have duplicate data in the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex: the table will have multiple rows for an empoyee when he has changed the department.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Darshan&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 15:44:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4638576#M177599</guid>
      <dc:creator>DarshanKumar</dc:creator>
      <dc:date>2025-04-04T15:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating active employees in each month of a year using hire date and end date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4639083#M177617</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1253949" data-lia-user-login="DarshanKumar" class="lia-mention lia-mention-user"&gt;DarshanKumar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's a very relevant question which happens all the time in the real world scenario.&amp;nbsp; &amp;nbsp;You can deal with this very common situation by maintaining the employee change log table where you have start dates and end dates where employees change departments in the table with department field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Headcount =
SUMX (
    'Employee Change',
    IF (
        MAX ( 'Calendar'[Date] ) &amp;gt;= 'Employee Change'[Hire date]
            &amp;amp;&amp;amp; MAX ( 'Calendar'[Date] ) &amp;lt;= 'Employee Change'[Leaving date],
        1,
        BLANK ()
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;The dax measure above will take care of the headcount situation properly even when the employees change departments as long as the change log for department is also properly maintained as a fact table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This formula checks if the current report date falls between the hire and leave dates, so even if the employee appears multiple times due to transfers, they'll only be counted once if they're still active.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Sat, 05 Apr 2025 03:57:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-active-employees-in-each-month-of-a-year-using-hire/m-p/4639083#M177617</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2025-04-05T03:57:00Z</dc:date>
    </item>
  </channel>
</rss>

