<?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: Distinct Count based on two date columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-based-on-two-date-columns/m-p/3139627#M112045</link>
    <description>&lt;P&gt;Awesome, worked like charm&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Mar 2023 19:06:49 GMT</pubDate>
    <dc:creator>frankyjones</dc:creator>
    <dc:date>2023-03-17T19:06:49Z</dc:date>
    <item>
      <title>Distinct Count based on two date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-based-on-two-date-columns/m-p/3139301#M112017</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am trying to retrieve a value from a table that has certain conditions (between two dates), but I got lost on my DAX. It would be great if one of you was able to help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Employee Table looks something like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;EMPLOYEE_ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CONTRACT_STARTDATE&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CONTRACT_ENDDATE&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12545&lt;/TD&gt;&lt;TD&gt;1-1-2022&lt;/TD&gt;&lt;TD&gt;12-31-2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12545&lt;/TD&gt;&lt;TD&gt;1-1-2023&lt;/TD&gt;&lt;TD&gt;12-31-2023&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;54654&lt;/TD&gt;&lt;TD&gt;5-1-2021&lt;/TD&gt;&lt;TD&gt;9-30-2021&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;54654&lt;/TD&gt;&lt;TD&gt;10-1-2021&lt;/TD&gt;&lt;TD&gt;12-31-2021&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;54654&lt;/TD&gt;&lt;TD&gt;1-1-2022&lt;/TD&gt;&lt;TD&gt;12-31-2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;54654&lt;/TD&gt;&lt;TD&gt;1-1-2023&lt;/TD&gt;&lt;TD&gt;1-1-2024&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;84562&lt;/TD&gt;&lt;TD&gt;6-1-2022&lt;/TD&gt;&lt;TD&gt;6-1-2026&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;21536&lt;/TD&gt;&lt;TD&gt;1-1-2022&lt;/TD&gt;&lt;TD&gt;12-31-2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;21536&lt;/TD&gt;&lt;TD&gt;1-1-2023&lt;/TD&gt;&lt;TD&gt;1-1-2027&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a measure that counts the number of employees in a certain date range that is filtered with date slicers (based on my date table) in my report. The Employee table can have an inactive many to one relationship with the date table (not an active one, because it's a dim table).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a measure that works that calculates the number of employees that started in the period that is selected with the inactive relationship, but that's not the calculation I want. I want the number of employees within the range of Contract start and Contract end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Number of employees = CALCULATE(DISTINCTCOUNT('Dim Employees'[EMPLOYEE_ID]), USERELATIONSHIP('Dim Calender'[DATE], 'Dim Employees'[CONTRACT_STARTDATE]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to solve this? Preferably within the dax measure itself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 15:49:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-based-on-two-date-columns/m-p/3139301#M112017</guid>
      <dc:creator>frankyjones</dc:creator>
      <dc:date>2023-03-17T15:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count based on two date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-based-on-two-date-columns/m-p/3139470#M112030</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="531781" data-lia-user-login="frankyjones" class="lia-mention lia-mention-user"&gt;frankyjones&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;Number of employees =&lt;BR /&gt;VAR MaxDate =&lt;BR /&gt;MAX ( 'Calender'[DATE] )&lt;BR /&gt;VAR MinDate =&lt;BR /&gt;MIN ( 'Calender'[DATE] )&lt;BR /&gt;RETURN&lt;BR /&gt;COUNTROWS (&lt;BR /&gt;FILTER (&lt;BR /&gt;VALUES ( 'Dim Employees'[EMPLOYEE_ID] ),&lt;BR /&gt;NOT ISEMPTY (&lt;BR /&gt;FILTER (&lt;BR /&gt;CALCULATETABLE ( 'Dim Employees' ),&lt;BR /&gt;'Dim Employees'[CONTRACT_STARTDATE] &amp;lt;= MaxDate&lt;BR /&gt;&amp;amp;&amp;amp; 'Dim Employees'[CONTRACT_ENDDATE] &amp;gt;= MinDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 17:09:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-based-on-two-date-columns/m-p/3139470#M112030</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-17T17:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count based on two date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-based-on-two-date-columns/m-p/3139627#M112045</link>
      <description>&lt;P&gt;Awesome, worked like charm&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 19:06:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-based-on-two-date-columns/m-p/3139627#M112045</guid>
      <dc:creator>frankyjones</dc:creator>
      <dc:date>2023-03-17T19:06:49Z</dc:date>
    </item>
  </channel>
</rss>

