<?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: Count number of employees from start date to end date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2897324#M94258</link>
    <description>&lt;P&gt;Worker perfectly!&lt;BR /&gt;Thank you so much for your help!&lt;/P&gt;</description>
    <pubDate>Thu, 10 Nov 2022 10:46:06 GMT</pubDate>
    <dc:creator>Ines_Raquel</dc:creator>
    <dc:date>2022-11-10T10:46:06Z</dc:date>
    <item>
      <title>Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892205#M93915</link>
      <description>&lt;P&gt;Hello, everyone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a metric based on the following logic:&lt;/P&gt;&lt;P&gt;Nº Employees :=&lt;BR /&gt;calculate(DISTINCTCOUNT('Employee'[ID]),&lt;BR /&gt;filter('Employee table',&lt;BR /&gt;year('Employee table'[Entry Date]) &amp;lt;= 2021&lt;BR /&gt;&amp;amp;&amp;amp; ('Employee table'[Leave Date] = BLANK() || (year('Employee table'[Leave Date]) &amp;gt;=2021))))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when i filter the date on PowerBI, it only displays employees that have the entry date of the filtered year.&lt;/P&gt;&lt;P&gt;For instance, if i select 2021, i need to see all employees that have not left until 2021. Not solely those with the entry date at 2021 like it's currently happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please, any help will be much appreciated!&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 12:39:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892205#M93915</guid>
      <dc:creator>Ines_Raquel</dc:creator>
      <dc:date>2022-11-08T12:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892613#M93929</link>
      <description>&lt;P&gt;try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Nº Employees :=
CALCULATE (
    DISTINCTCOUNT ( 'Employee'[ID] ),
    REMOVEFILTERS ( 'Employee table' ),
    YEAR ( 'Employee table'[Entry Date] ) &amp;lt;= 2021
        &amp;amp;&amp;amp; (
            ISBLANK ( 'Employee table'[Leave Date] )
                || ( YEAR ( 'Employee table'[Leave Date] ) &amp;gt;= 2021 )
        )
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Nov 2022 14:44:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892613#M93929</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-11-08T14:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892707#M93933</link>
      <description>&lt;P&gt;I appreciate your help.&lt;/P&gt;&lt;P&gt;However, 'REMOVEFILTERS' is not being recognized on AS.&amp;nbsp;&lt;BR /&gt;2021 was more of an example. The year is supposed to be whatever is filtered.&lt;BR /&gt;&lt;BR /&gt;Any work arounds?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 15:11:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892707#M93933</guid>
      <dc:creator>Ines_Raquel</dc:creator>
      <dc:date>2022-11-08T15:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892713#M93934</link>
      <description>&lt;P&gt;You could try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Nº Employees :=
VAR MaxDate =
    YEAR ( MAX ( 'Date'[Date] ) )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Employee'[ID] ),
        ALL ( 'Employee table' ),
        YEAR ( 'Employee table'[Entry Date] ) &amp;lt;= MaxDate
            &amp;amp;&amp;amp; (
                ISBLANK ( 'Employee table'[Leave Date] )
                    || ( YEAR ( 'Employee table'[Leave Date] ) &amp;gt;= MaxDate )
            )
    )
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Nov 2022 15:16:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892713#M93934</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-11-08T15:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892799#M93943</link>
      <description>&lt;P&gt;I adptaded your formula a bit and got the right results for each year:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;NumEmp:=
VAR endOfPeriod =MAX ( 'Dim Date'[Date])
VAR startOfPeriod = MIN( 'Dim Date'[Date] )
RETURN
CALCULATE (
DISTINCTCOUNT('Fact Internal Employee'[NIF Employee]),
FILTER (
ALL('Fact Internal Employee'),
( ('Fact Internal Employee'[Employment Date] &amp;lt;= endOfPeriod )
&amp;amp;&amp;amp; ('Fact Internal Employee'[Resignation Date] &amp;gt;= startOfPeriod || 'Fact Internal Employee'[Resignation Date] = BLANK()))
))
    )&lt;/LI-CODE&gt;&lt;P&gt;The problem is that when i try to create an object with it against any other field, it presents repeated values:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Don't know if it helps, but the relationship is between Employee[entry date] and Date[Date]&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 15:52:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2892799#M93943</guid>
      <dc:creator>Ines_Raquel</dc:creator>
      <dc:date>2022-11-08T15:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2893044#M93961</link>
      <description>&lt;P&gt;you're removing all the filters on the employee table. try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;NumEmp :=
VAR endOfPeriod =
    MAX ( 'Dim Date'[Date] )
VAR startOfPeriod =
    MIN ( 'Dim Date'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Fact Internal Employee'[NIF Employee] ),
        REMOVEFILTERS ( 'Dim Date' ),
        'Fact Internal Employee'[Employment Date] &amp;lt;= endOfPeriod
            &amp;amp;&amp;amp; (
                'Fact Internal Employee'[Resignation Date] &amp;gt;= startOfPeriod
                    || ISBLANK ( 'Fact Internal Employee'[Resignation Date] )
            )
    )
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Nov 2022 16:58:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2893044#M93961</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-11-08T16:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2893112#M93967</link>
      <description>&lt;P&gt;Unfortunaly it doesn't work due to REMOVEFILTERS not being recognized. When i try to replace it with ALL i get an error saying "The expression contains multiple columns..." &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 17:28:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2893112#M93967</guid>
      <dc:creator>Ines_Raquel</dc:creator>
      <dc:date>2022-11-08T17:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2895002#M94070</link>
      <description>&lt;P&gt;Last thing I can think to try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;NumEmp :=
VAR endOfPeriod =
    MAX ( 'Dim Date'[Date] )
VAR startOfPeriod =
    MIN ( 'Dim Date'[Date] )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Fact Internal Employee'[NIF Employee] ),
        ALL ( 'Dim Date' ),
        'Fact Internal Employee'[Employment Date] &amp;lt;= endOfPeriod,
        (
                'Fact Internal Employee'[Resignation Date] &amp;gt;= startOfPeriod
                    || ISBLANK ( 'Fact Internal Employee'[Resignation Date] )
            )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 09 Nov 2022 09:50:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2895002#M94070</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-11-09T09:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of employees from start date to end date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2897324#M94258</link>
      <description>&lt;P&gt;Worker perfectly!&lt;BR /&gt;Thank you so much for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 10:46:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-number-of-employees-from-start-date-to-end-date/m-p/2897324#M94258</guid>
      <dc:creator>Ines_Raquel</dc:creator>
      <dc:date>2022-11-10T10:46:06Z</dc:date>
    </item>
  </channel>
</rss>

