<?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: Number of employees - Formula in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3903593#M152102</link>
    <description>&lt;LI-CODE lang="markup"&gt;Headcount =
CALCULATE (
    DISTINCTCOUNT ( hra_datasource[Index] ),
    hra_datasource[start_date] &amp;lt;= MIN ( 'CALENDAR'[Date] ),
    COALESCE ( hra_datasource[end_date], TODAY () ) &amp;gt;= MAX ( 'CALENDAR'[Date] )
)&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 08 May 2024 23:30:57 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-05-08T23:30:57Z</dc:date>
    <item>
      <title>Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3902565#M152071</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to show the number of employees at indicated time yet when filtered by year for example 2022", the formula counts currently employed and people who left as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Headcount = CALCULATE(DISTINCTCOUNT(hra_datasource[Index]),
FILTER(VALUES(hra_datasource[start_date]), hra_datasource[start_date]&amp;lt;=MAX('CALENDAR'[Date])),
FILTER(VALUES(hra_datasource[end_date]), OR(hra_datasource[end_date] &amp;gt;=MAX('CALENDAR'[Date]),ISBLANK(hra_datasource[end_date]))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dashboard looks like that&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;The correct number that should appear is "number of employees at indicated time" - "Leavers". How can I improve my formula to count only currently hired?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 14:22:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3902565#M152071</guid>
      <dc:creator>syl-ade</dc:creator>
      <dc:date>2024-05-08T14:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3903593#M152102</link>
      <description>&lt;LI-CODE lang="markup"&gt;Headcount =
CALCULATE (
    DISTINCTCOUNT ( hra_datasource[Index] ),
    hra_datasource[start_date] &amp;lt;= MIN ( 'CALENDAR'[Date] ),
    COALESCE ( hra_datasource[end_date], TODAY () ) &amp;gt;= MAX ( 'CALENDAR'[Date] )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 May 2024 23:30:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3903593#M152102</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-05-08T23:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3905677#M152154</link>
      <description>&lt;P&gt;Hi Ibendlin,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code does not seem to work well unfortunately.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 13:26:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3905677#M152154</guid>
      <dc:creator>syl-ade</dc:creator>
      <dc:date>2024-05-09T13:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3905813#M152156</link>
      <description>&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 14:13:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3905813#M152156</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-05-09T14:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3909791#M152278</link>
      <description>&lt;P&gt;Sample data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;first_name&lt;/TD&gt;&lt;TD&gt;surname&lt;/TD&gt;&lt;TD&gt;gender&lt;/TD&gt;&lt;TD&gt;employment_type&lt;/TD&gt;&lt;TD&gt;company&lt;/TD&gt;&lt;TD&gt;business unit&lt;/TD&gt;&lt;TD&gt;N+2&lt;/TD&gt;&lt;TD&gt;start_date&lt;/TD&gt;&lt;TD&gt;end_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;Smith&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;B2B&lt;/TD&gt;&lt;TD&gt;Company A&lt;/TD&gt;&lt;TD&gt;BUIS&lt;/TD&gt;&lt;TD&gt;SIS (Sales IS)&lt;/TD&gt;&lt;TD&gt;2007-09-01&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Emily&lt;/TD&gt;&lt;TD&gt;Johnson&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;B2B&lt;/TD&gt;&lt;TD&gt;Company A&lt;/TD&gt;&lt;TD&gt;BUCL&lt;/TD&gt;&lt;TD&gt;Delivery Modern Work&amp;amp;Security&lt;/TD&gt;&lt;TD&gt;2009-02-12&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Michael&lt;/TD&gt;&lt;TD&gt;Williams&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;B2B&lt;/TD&gt;&lt;TD&gt;Company A&lt;/TD&gt;&lt;TD&gt;BUCL&lt;/TD&gt;&lt;TD&gt;Sales Modern Work&amp;amp;Security (SMS)&lt;/TD&gt;&lt;TD&gt;2009-02-12&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Sarah&lt;/TD&gt;&lt;TD&gt;Brown&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;FTE&lt;/TD&gt;&lt;TD&gt;Company A&lt;/TD&gt;&lt;TD&gt;BUMS&lt;/TD&gt;&lt;TD&gt;DMS (Delivery MS)&lt;/TD&gt;&lt;TD&gt;2022-10-10&lt;/TD&gt;&lt;TD&gt;2023-07-31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;James&lt;/TD&gt;&lt;TD&gt;Jones&lt;/TD&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;FTE&lt;/TD&gt;&lt;TD&gt;Company B&lt;/TD&gt;&lt;TD&gt;BUCS&lt;/TD&gt;&lt;TD&gt;SNS (Sales NS)&lt;/TD&gt;&lt;TD&gt;2022-11-02&lt;/TD&gt;&lt;TD&gt;2023-04-15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Emma&lt;/TD&gt;&lt;TD&gt;Davis&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;FTE&lt;/TD&gt;&lt;TD&gt;Company B&lt;/TD&gt;&lt;TD&gt;BUST&lt;/TD&gt;&lt;TD&gt;PRM&lt;/TD&gt;&lt;TD&gt;2022-12-01&lt;/TD&gt;&lt;TD&gt;2023-02-28&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jacob&lt;/TD&gt;&lt;TD&gt;Brendon&lt;/TD&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;CA&lt;/TD&gt;&lt;TD&gt;Company A&lt;/TD&gt;&lt;TD&gt;BUCL&lt;/TD&gt;&lt;TD&gt;Hybrid Cloud &amp;amp; Data &amp;amp; AI&lt;/TD&gt;&lt;TD&gt;2022-12-01&lt;/TD&gt;&lt;TD&gt;2024-03-31&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the model there are two 1-to-many inactive relationships:&lt;/P&gt;&lt;P&gt;1. date 1---* start_date&lt;/P&gt;&lt;P&gt;2. date 1---* end_date&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 19:49:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3909791#M152278</guid>
      <dc:creator>syl-ade</dc:creator>
      <dc:date>2024-05-10T19:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3909833#M152280</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see attached&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 20:55:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3909833#M152280</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-05-10T20:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3910389#M152295</link>
      <description>&lt;P&gt;It's not possible to put the HC calculation on the Card Visualisation.&amp;nbsp;&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;</description>
      <pubDate>Sat, 11 May 2024 07:11:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3910389#M152295</guid>
      <dc:creator>syl-ade</dc:creator>
      <dc:date>2024-05-11T07:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3910593#M152304</link>
      <description>&lt;P&gt;Which number do you expect to show?&lt;/P&gt;</description>
      <pubDate>Sat, 11 May 2024 11:58:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3910593#M152304</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-05-11T11:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Number of employees - Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3910837#M152312</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408321" data-lia-user-login="syl-ade" class="lia-mention lia-mention-user"&gt;syl-ade&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've created a simple dummy data to show the sample headcount calculation.&amp;nbsp; There are multiple ways to calculate headcount, but the important thing is that you create a data model with your employee table and calendar table as disconnected tables.&amp;nbsp; This is crutial for performing fiexible headcount analysis which frees you from the time dimension constraints.&amp;nbsp; One observation I made regarding your original formula is that you are using OR instead of &amp;amp;&amp;amp;, and for headcount calcualation, both after the starting date AND before the termination date conditions have to be met, so OR is not appropriate for headcount calculation.&amp;nbsp; Also, another point is that while the starting date has all the rows with date values, I suppose end_date has many blank values as some of the employees have still not left the company at the point of preparing the headcount analysis.&amp;nbsp; In the long run, everyone leaves the company but it is the fact that employee table contains blank values for end date for current employees.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to deal with blank values in the end_date field, you can create a calculated column to say that if it is blank, certain date in the future should be filled in, such as shown below.&amp;nbsp; Let's call it "Adjusted end date" for this example.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;I've tweaked your original formula to produce the headcount analysis like below:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;There are multiple ways to produce the same output, and another way is to use sumx formula like below:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;There's an article which discusses headcount calculation in the link below, but I guess you are on the right track, with respect to the use of disconnected tables, and just needed to fix "OR" part to "&amp;amp;&amp;amp;" and then also, needed to deal with blank values in your end_date field as typically, employee tables end date fields have blank values for current employees.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://p3adaptive.com/finding-the-magic-part-2-on-the-way-to-data-happiness/" target="_blank" rel="noopener"&gt;https://p3adaptive.com/finding-the-magic-part-2-on-the-way-to-data-happiness/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I attach an example pbix file with the fake data I created mimicking your table name.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Sat, 11 May 2024 14:56:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Number-of-employees-Formula/m-p/3910837#M152312</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2024-05-11T14:56:29Z</dc:date>
    </item>
  </channel>
</rss>

