<?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: Lookupvalue between Start Date and End Date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookupvalue-between-Start-Date-and-End-Date/m-p/738562#M2162</link>
    <description>&lt;P&gt;this syntax should work:&lt;/P&gt;
&lt;PRE&gt;Department =
VAR __RelevantEmployeeRows =
    FILTER (
        'Employees',
        'Employees'[Username] = 'Printer'[Username]
            &amp;amp;&amp;amp; 'Employees'[Start Date] &amp;lt;= 'Printer'[Date]
            &amp;amp;&amp;amp; 'Employees'[End Date] &amp;gt;= 'Printer'[Date]
    )
VAR __RelevantDepartments =
    DISTINCT (
        SELECTCOLUMNS ( __RelevantEmployeeRows, "Departments", 'Employees'[Department] )
    )
RETURN
    CONCATENATEX ( __RelevantDepartments, [Departments], "," )
&lt;/PRE&gt;
&lt;P&gt;the code assumes that there always is not null end date for each row in the Employees table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd also suggest to remove the many:many relationship in favour of a separate table with unique Usernames and 1:many, many2many relationships are not what most users think they are AND quite often if they have Both filtering direction are causing the relationship ambiguity - see detailed explanation here:&lt;BR /&gt;&lt;A href="https://sqlbits.com/Sessions/Event18/Different_types_of_many-to-many_relationships_in_Power_BI" target="_blank" rel="noopener"&gt;https://sqlbits.com/Sessions/Event18/Different_types_of_many-to-many_relationships_in_Power_BI&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jul 2019 08:47:37 GMT</pubDate>
    <dc:creator>Stachu</dc:creator>
    <dc:date>2019-07-12T08:47:37Z</dc:date>
    <item>
      <title>Lookupvalue between Start Date and End Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookupvalue-between-Start-Date-and-End-Date/m-p/737662#M2118</link>
      <description>&lt;P&gt;I need to create a calculated column named Printer[Department], with a lookup formula from Employees table, considering start date and end date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this with &lt;STRONG&gt;no sucess&lt;/STRONG&gt;:&lt;/P&gt;&lt;PRE&gt;Calculate(Values(Employees[Department]);&lt;BR /&gt;Filter ( Employees;&lt;BR /&gt;Printer[Date] &amp;gt;= Employees[Start Date]
&amp;amp;&amp;amp; Printer[Date] &amp;lt;= Employees[End Date]
&amp;amp;&amp;amp; Printer[Username] = Employees[Username]))&lt;/PRE&gt;&lt;P&gt;The relation is many to many, because at employees table a username(employee) can have one or more Department, regarding the period.&lt;/P&gt;&lt;P&gt;Example: the first username worked in 2 Departments.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 14:40:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookupvalue-between-Start-Date-and-End-Date/m-p/737662#M2118</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-11T14:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Lookupvalue between Start Date and End Date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookupvalue-between-Start-Date-and-End-Date/m-p/738562#M2162</link>
      <description>&lt;P&gt;this syntax should work:&lt;/P&gt;
&lt;PRE&gt;Department =
VAR __RelevantEmployeeRows =
    FILTER (
        'Employees',
        'Employees'[Username] = 'Printer'[Username]
            &amp;amp;&amp;amp; 'Employees'[Start Date] &amp;lt;= 'Printer'[Date]
            &amp;amp;&amp;amp; 'Employees'[End Date] &amp;gt;= 'Printer'[Date]
    )
VAR __RelevantDepartments =
    DISTINCT (
        SELECTCOLUMNS ( __RelevantEmployeeRows, "Departments", 'Employees'[Department] )
    )
RETURN
    CONCATENATEX ( __RelevantDepartments, [Departments], "," )
&lt;/PRE&gt;
&lt;P&gt;the code assumes that there always is not null end date for each row in the Employees table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd also suggest to remove the many:many relationship in favour of a separate table with unique Usernames and 1:many, many2many relationships are not what most users think they are AND quite often if they have Both filtering direction are causing the relationship ambiguity - see detailed explanation here:&lt;BR /&gt;&lt;A href="https://sqlbits.com/Sessions/Event18/Different_types_of_many-to-many_relationships_in_Power_BI" target="_blank" rel="noopener"&gt;https://sqlbits.com/Sessions/Event18/Different_types_of_many-to-many_relationships_in_Power_BI&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 08:47:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookupvalue-between-Start-Date-and-End-Date/m-p/738562#M2162</guid>
      <dc:creator>Stachu</dc:creator>
      <dc:date>2019-07-12T08:47:37Z</dc:date>
    </item>
  </channel>
</rss>

