<?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 Count unique employees per month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1328839#M23497</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I am struggling to count unique employees per month. I can do it in excel, but not in power bi. Please see the data, PeopleCount1 formula and excel pivot (showing the correct result). Could somebody please help me with the DAX formula for PeopleCount? I suspect it is because of the way I have structured my data model.&lt;/P&gt;&lt;P&gt;&lt;A href="http://michellepace.com/pics/Q.08%20Data.xlsx" target="_blank" rel="noopener"&gt;Q.08 Data.xlsx&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;A href="http://michellepace.com/pics/Q.08%20Varying%20count%20of%20people%20over%20time.pbix" target="_blank" rel="noopener"&gt;Q.08 Varying count of people over time.pbix&lt;/A&gt;&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;Thanks in advance, Michelle&lt;/P&gt;</description>
    <pubDate>Thu, 27 Aug 2020 12:02:51 GMT</pubDate>
    <dc:creator>michellepace</dc:creator>
    <dc:date>2020-08-27T12:02:51Z</dc:date>
    <item>
      <title>Count unique employees per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1328839#M23497</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I am struggling to count unique employees per month. I can do it in excel, but not in power bi. Please see the data, PeopleCount1 formula and excel pivot (showing the correct result). Could somebody please help me with the DAX formula for PeopleCount? I suspect it is because of the way I have structured my data model.&lt;/P&gt;&lt;P&gt;&lt;A href="http://michellepace.com/pics/Q.08%20Data.xlsx" target="_blank" rel="noopener"&gt;Q.08 Data.xlsx&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;A href="http://michellepace.com/pics/Q.08%20Varying%20count%20of%20people%20over%20time.pbix" target="_blank" rel="noopener"&gt;Q.08 Varying count of people over time.pbix&lt;/A&gt;&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;Thanks in advance, Michelle&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 12:02:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1328839#M23497</guid>
      <dc:creator>michellepace</dc:creator>
      <dc:date>2020-08-27T12:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique employees per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1328848#M23499</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="133502" data-lia-user-login="michellepace" class="lia-mention lia-mention-user"&gt;michellepace&lt;/a&gt;&amp;nbsp; Use this:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;PeopleCount1 =
CALCULATE (
    DISTINCTCOUNTNOBLANK ( Employees[Employee #] ),
    CROSSFILTER ( EmployeeHours[Index], Employees[Index], BOTH )
)
&lt;/LI-CODE&gt;
&lt;P&gt;Also, that date table is incorrect, make sure you have all the dates for calendar/fiscal year to avoid any further issues.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 12:11:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1328848#M23499</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2020-08-27T12:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique employees per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329604#M23536</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236628" data-lia-user-login="AntrikshSharma" class="lia-mention lia-mention-user"&gt;AntrikshSharma&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for such an eloquent solution.&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Question 1:&lt;/STRONG&gt;&lt;/FONT&gt; Do you perhaps have a link where I could read up on how/when to use crossfilter?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#808080"&gt;&amp;gt;&amp;nbsp;that date table is incorrect, ensure you have all the dates for calendar/fiscal year to avoid issues.&amp;nbsp;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;Thanks for that. With my dates table, I only actually populate a date row where I have data existing (for example, I never have employee hours on a Sunday so many of the Sunday rows will not be in my Dates table). It may be an obvious answer, but just to be sure:&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;Question 2:&lt;/STRONG&gt;&lt;/FONT&gt; should a Date table always contain consecutive dates (even if I don't have data for those dates)?&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;I am really new to "designing" data models.&amp;nbsp;I have become suspicious that my model is incorrectly designed as it does not seem right that creating a measure of a simple employee count needs to be that sophisticated.&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;Question 3:&lt;/FONT&gt;&lt;/STRONG&gt; in your opinion is there anything inherently flawed in my design?&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;Question 4:&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(just a little one) What format did you choose when writing your reply to get the DAX code to display so nicely? Did you choose perhaps "python"&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;Thank you once again.. and especially for your patience.&lt;BR /&gt;Michelle&lt;/DIV&gt;</description>
      <pubDate>Thu, 27 Aug 2020 16:24:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329604#M23536</guid>
      <dc:creator>michellepace</dc:creator>
      <dc:date>2020-08-27T16:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique employees per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329666#M23543</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="133502" data-lia-user-login="michellepace" class="lia-mention lia-mention-user"&gt;michellepace&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A1 - Refer to this page and the articles at the bottom:&amp;nbsp;&lt;A href="https://dax.guide/crossfilter/" target="_blank" rel="noopener"&gt;https://dax.guide/crossfilter/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A2 - Yes, date table should always be complete calendar or fiscal year, think of it as a ladder, if you want to go 4 days back or 5 days in future you would need each step to be there otherwise you won't be able to ascend or descend, and time intelligence functions won't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A3 - The data model looks fine, the only reason we have to use CROSSFILTER is because you are counting DISTINCT in Employees table and then trying to filter it by both company and dates, for company it works but since Dates is not directly related to Employees we have to make the filter from date travel to EmployeeHours and then further make it travel to Employees, think of it as a bridge that we opened only for the duration of calculation.&amp;nbsp; You can achieve the same result with using bi-directional filters and Expanded table filtering&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Bi-directional - Edit the relationship between Employees and EmployeeHours ( Not a recommended method but will help in visualizing CROSSFILTER, don't use this ever!! as the filters from Dates will always be able to Filter Employees table and as the model grows you will get confuse why a measure doens't returns the required result. )&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Expanded tables - Disable bi-directional filtering from the previous point and make it single directional and then use this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;PeopleCount1 =
CALCULATE (
    DISTINCTCOUNTNOBLANK ( Employees[Employee #] ),
    EmployeeHours 
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EmployeeHours in the above code is where table expansion happens and all the table that are related to EmployeeHours with Many: 1 relationship are joined to EmployeeHours with a LEFT JOIN, read this article.&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/expanded-tables-in-dax/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/expanded-tables-in-dax/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A4 - I have used&amp;nbsp;&lt;A href="https://www.daxformatter.com/" target="_blank" rel="noopener"&gt;https://www.daxformatter.com/&lt;/A&gt;&amp;nbsp; to format and indent &amp;amp; then PHP from the options&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 16:52:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329666#M23543</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2020-08-27T16:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique employees per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329902#M23550</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Antriksh this is an incredibly useful answer which I will refer back to many times. Thank you so much for the clear and (very)&amp;nbsp; educational explanation. A really top reply, thank you once again.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 18:24:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329902#M23550</guid>
      <dc:creator>michellepace</dc:creator>
      <dc:date>2020-08-27T18:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Count unique employees per month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329911#M23551</link>
      <description>You're welcome! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 27 Aug 2020 18:33:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-unique-employees-per-month/m-p/1329911#M23551</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2020-08-27T18:33:19Z</dc:date>
    </item>
  </channel>
</rss>

