<?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 Calculating head cound using dax measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/749213#M2632</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I have 2 tables&lt;/P&gt;&lt;P&gt;1 table is date table with following fields: date, month, quarter, year, yearmonth,yearnumber&lt;/P&gt;&lt;P&gt;2nd table is Employee table with following fields: EmpID, Hired Date, Termination Date,&lt;BR /&gt;employees that are active have a blank termination date.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I am trying to do employee head count by month and year. Wrote a dax measure using forums but it is showing me blank results:&lt;/P&gt;&lt;P&gt;Would be gratefull for any help here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;PRE&gt;HeadCount = 
var endperiod=MAX('date'[Date])
var startperiod=MIN('date'[Date])
return 
CALCULATE(DISTINCTCOUNT('shared User'[EmployeeId]),FILTER(ALL('shared User'),('shared User'[HireDate]&amp;lt;=endperiod &amp;amp;&amp;amp; 'shared User'[TerminationDate]&amp;gt;=startperiod)))&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 25 Jul 2019 15:54:00 GMT</pubDate>
    <dc:creator>mady90</dc:creator>
    <dc:date>2019-07-25T15:54:00Z</dc:date>
    <item>
      <title>Calculating head cound using dax measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/749213#M2632</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I have 2 tables&lt;/P&gt;&lt;P&gt;1 table is date table with following fields: date, month, quarter, year, yearmonth,yearnumber&lt;/P&gt;&lt;P&gt;2nd table is Employee table with following fields: EmpID, Hired Date, Termination Date,&lt;BR /&gt;employees that are active have a blank termination date.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I am trying to do employee head count by month and year. Wrote a dax measure using forums but it is showing me blank results:&lt;/P&gt;&lt;P&gt;Would be gratefull for any help here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;PRE&gt;HeadCount = 
var endperiod=MAX('date'[Date])
var startperiod=MIN('date'[Date])
return 
CALCULATE(DISTINCTCOUNT('shared User'[EmployeeId]),FILTER(ALL('shared User'),('shared User'[HireDate]&amp;lt;=endperiod &amp;amp;&amp;amp; 'shared User'[TerminationDate]&amp;gt;=startperiod)))&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:54:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/749213#M2632</guid>
      <dc:creator>mady90</dc:creator>
      <dc:date>2019-07-25T15:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating head cound using dax measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/749567#M2649</link>
      <description>&lt;PRE&gt;-- Assumption is that an Employee is 
-- active within a period of time [__start, __end] if
-- the intersection with [HireDate, TerminationDate]
-- is not empty, that is
-- intersection(
--		[__start, __end],
--		[HireDate, TerminationDate]
--	) is not empty.
-- This is logically equivalent to saying
-- that it's NOT TRUE that
-- HireDate &amp;gt; __end OR TerminationDate &amp;lt; __start,
-- which means
-- HireDate &amp;lt;= __end AND TerminationDate &amp;gt;= __start.
-- An adjustment is needed when TerminationDate is BLANK.

HeadCount =
VAR __end = MAX ( 'date'[Date] )
VAR __start = MIN ( 'date'[Date] )
var __headCount =
    CALCULATE (
        DISTINCTCOUNT ( 'shared User'[EmployeeId] ),
        'shared User'[HireDate] &amp;lt;= __end,
        OR(
        	'shared User'[TerminationDate] &amp;gt;= __start,
        	ISBLANK( 'shared User'[TerminationDate] )
        )&lt;BR /&gt;    )
RETURN
	__headCount&lt;/PRE&gt;&lt;P&gt;This will work on the assumption that the 'date' table is not connected to the 'shared User' table. If it is, then a different formula would be required. And this also depends on which relationships are active between the tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 00:07:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/749567#M2649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-26T00:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating head cound using dax measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/799756#M4806</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use this formula as a measure. But it says that "A function 'calculate' has been used in a true/false expression that is used as a table filter expression. This is not allowed". Do you know what I did wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 15:35:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/799756#M4806</guid>
      <dc:creator>SofG</dc:creator>
      <dc:date>2019-09-23T15:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating head cound using dax measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/800635#M4826</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;HeadCount =
VAR __end = MAX ( 'date'[Date] )
VAR __start = MIN ( 'date'[Date] )
var __headCount =
    CALCULATE (
        DISTINCTCOUNT ( 'shared User'[EmployeeId] ),
        'shared User'[HireDate] &amp;lt;= __end,
        OR(
        	'shared User'[TerminationDate] &amp;gt;= __start,
        	'shared User'[TerminationDate] = BLANK()
        )
    )
RETURN
	__headCount&lt;/PRE&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 10:48:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-head-cound-using-dax-measure/m-p/800635#M4826</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-24T10:48:41Z</dc:date>
    </item>
  </channel>
</rss>

