<?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 Lookup value based on date between a range in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/896991#M8091</link>
    <description>&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;Timesheets - has staff hours and the date they worked those hours&lt;/P&gt;&lt;P&gt;Career History - has a Start Date and End Date that an employee worked at a particular Branch&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Timesheets table, what is the Syntax for adding a CALCULATED COLUMN which tells me their branch, on the day they recorded their hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Example, Fred moves moves from the Sheffield branch to the London branch on 01/01/2020:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current Timesheet table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Staff_ID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;TimesheetDate&lt;/TD&gt;&lt;TD&gt;Hours&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;23/12/2019&lt;/TD&gt;&lt;TD&gt;7.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;03/01/2020&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current Career History table (end date is blank if they still work at that branch):&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Staff_ID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;StartDate&lt;/TD&gt;&lt;TD&gt;EndDate&lt;/TD&gt;&lt;TD&gt;Branch&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;01/07/2019&lt;/TD&gt;&lt;TD&gt;31/12/2019&lt;/TD&gt;&lt;TD&gt;Sheffield&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;01/01/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;London&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result I want in the Timesheet table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Staff_ID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;TimesheetDate&lt;/TD&gt;&lt;TD&gt;Hours&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Branch&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;23/12/2019&lt;/TD&gt;&lt;TD&gt;7.5&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Sheffield&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;03/01/2020&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;London&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me by giving the syntax for the calculated column.&lt;/P&gt;</description>
    <pubDate>Sat, 11 Jan 2020 16:06:27 GMT</pubDate>
    <dc:creator>RoseyAlexa</dc:creator>
    <dc:date>2020-01-11T16:06:27Z</dc:date>
    <item>
      <title>Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/896991#M8091</link>
      <description>&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;Timesheets - has staff hours and the date they worked those hours&lt;/P&gt;&lt;P&gt;Career History - has a Start Date and End Date that an employee worked at a particular Branch&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Timesheets table, what is the Syntax for adding a CALCULATED COLUMN which tells me their branch, on the day they recorded their hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Example, Fred moves moves from the Sheffield branch to the London branch on 01/01/2020:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current Timesheet table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Staff_ID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;TimesheetDate&lt;/TD&gt;&lt;TD&gt;Hours&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;23/12/2019&lt;/TD&gt;&lt;TD&gt;7.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;03/01/2020&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current Career History table (end date is blank if they still work at that branch):&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Staff_ID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;StartDate&lt;/TD&gt;&lt;TD&gt;EndDate&lt;/TD&gt;&lt;TD&gt;Branch&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;01/07/2019&lt;/TD&gt;&lt;TD&gt;31/12/2019&lt;/TD&gt;&lt;TD&gt;Sheffield&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;01/01/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;London&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result I want in the Timesheet table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Staff_ID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;TimesheetDate&lt;/TD&gt;&lt;TD&gt;Hours&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Branch&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;23/12/2019&lt;/TD&gt;&lt;TD&gt;7.5&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Sheffield&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;030&lt;/TD&gt;&lt;TD&gt;Fred Jones&lt;/TD&gt;&lt;TD&gt;03/01/2020&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;London&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me by giving the syntax for the calculated column.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 16:06:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/896991#M8091</guid>
      <dc:creator>RoseyAlexa</dc:creator>
      <dc:date>2020-01-11T16:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/896995#M8093</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="94025" data-lia-user-login="RoseyAlexa" class="lia-mention lia-mention-user"&gt;RoseyAlexa&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;This should meet your requirements.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Branch = 
VAR staffID = Timesheet[Staff_ID]
VAR timeSheetDate = Timesheet[TimesheetDate]
RETURN
CALCULATE(SELECTEDVALUE(Careerhistory[Branch], "Multi"), FILTER(Careerhistory, Careerhistory[Staff_ID] = staffID &amp;amp;&amp;amp; Careerhistory[StartDate] &amp;lt;= timeSheetDate &amp;amp;&amp;amp; OR(Careerhistory[EndDate] = BLANK(), Careerhistory[EndDate] &amp;gt; timeSheetDate)))&lt;/LI-CODE&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Djerro123&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;If this answered your question, please &lt;STRONG&gt;mark it as the Solution&lt;/STRONG&gt;. This also helps others to find what they are looking for.&lt;/P&gt;&lt;P&gt;Keep those &lt;STRONG&gt;thumbs up&lt;/STRONG&gt; coming! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 16:41:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/896995#M8093</guid>
      <dc:creator>JarroVGIT</dc:creator>
      <dc:date>2020-01-11T16:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897004#M8097</link>
      <description>&lt;P&gt;Nearly right, but it returns a value of Multi for nearly every row.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 17:23:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897004#M8097</guid>
      <dc:creator>RoseyAlexa</dc:creator>
      <dc:date>2020-01-11T17:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897006#M8099</link>
      <description>&lt;P&gt;Please find my PBIX here where this solution fits your requirements applied to the testdata your provided. If the solution has a different outcome in your real dataset, then the difference between the your dataset and the dataset you provided to us are likely the cause of the malfunctioning. Without knowing what your real dataset looks like, there is very little I can do?&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only thing I can think of: are your date columns of the type Date? (They weren't when I copied your test data into PBI)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!Ancq8HFZYL_aiIoUNv6XLc0V5ONqyg?e=kRTFV9" target="_blank" rel="noopener"&gt;https://1drv.ms/u/s!Ancq8HFZYL_aiIoUNv6XLc0V5ONqyg?e=kRTFV9&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Djerro123&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;If this answered your question, please &lt;STRONG&gt;mark it as the Solution&lt;/STRONG&gt;. This also helps others to find what they are looking for.&lt;/P&gt;&lt;P&gt;Keep those &lt;STRONG&gt;thumbs up&lt;/STRONG&gt; coming! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 17:32:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897006#M8099</guid>
      <dc:creator>JarroVGIT</dc:creator>
      <dc:date>2020-01-11T17:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897015#M8101</link>
      <description>&lt;P&gt;The real dataset is much larger. There are multiple entries for any one person on any one day, as they will have put time to a number of projects.&lt;/P&gt;&lt;P&gt;The tables I provided were just example tables created in the forum post.&lt;/P&gt;&lt;P&gt;I've checked and, yes, they are date fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried adding other data, to replicate it a little closer to the large dataset, and creating the same relationships as my main dataset.&lt;/P&gt;&lt;P&gt;But your PBIX is still working, and my main dataset is not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Must be something in the relationships I think.&lt;BR /&gt;Dont judge me on my table structures. I'm new at this stuff&lt;/P&gt;&lt;P&gt;&lt;A href="https://bondbryan-my.sharepoint.com/:i:/g/personal/r_alexander_bondbryan_co_uk/EYoTLQ03IVpKupoH-B0PQeABqlPQD7p2Sx3Jm8e29OzGvg?e=YXMkmL" target="_self"&gt;click here for table relationship image&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 18:10:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897015#M8101</guid>
      <dc:creator>RoseyAlexa</dc:creator>
      <dc:date>2020-01-11T18:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897026#M8102</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="94025" data-lia-user-login="RoseyAlexa" class="lia-mention lia-mention-user"&gt;RoseyAlexa&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;First off: no judgement from my side! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Everybody had to start at some point in PowerBI and most of us here are having fun helping people out with their specific cases, I learn a lot by helping others myself for example &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Back to your case; thanks for sharing the model! That really clarifies a few things for me. Could you please share the DAX of the calculated column you used? There might be a litle mistake when translating my solution to your specific column- and table names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Djerro123&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;If this answered your question, please &lt;STRONG&gt;mark it as the Solution&lt;/STRONG&gt;. This also helps others to find what they are looking for.&lt;/P&gt;&lt;P&gt;Keep those &lt;STRONG&gt;thumbs up&lt;/STRONG&gt; coming! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2020 18:59:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897026#M8102</guid>
      <dc:creator>JarroVGIT</dc:creator>
      <dc:date>2020-01-11T18:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897121#M8112</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="137611" data-lia-user-login="JarroVGIT" class="lia-mention lia-mention-user"&gt;JarroVGIT&lt;/a&gt;thanks for helping.&lt;/P&gt;&lt;P&gt;Here is what I translated your code into:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Timesheet Branch = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR staffID = 'Timesheets'[Staff_ID]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR timeSheetDate = 'Timesheets'[Timesheet Date]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE(SELECTEDVALUE('Career History'[Branch], "Multi"), FILTER('Career History', 'Career History'[Staff_ID] = staffID &amp;amp;&amp;amp; 'Career History'[Career History Start Date] &amp;lt;= timeSheetDate &amp;amp;&amp;amp; OR('Career History'[Career History End Date] = BLANK(), 'Career History'[Career History End Date]&amp;gt; timeSheetDate)))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 12 Jan 2020 09:52:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897121#M8112</guid>
      <dc:creator>RoseyAlexa</dc:creator>
      <dc:date>2020-01-12T09:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup value based on date between a range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897138#M8113</link>
      <description>&lt;P&gt;That seems to be correct. Is it possible to share your PBIX? You can PM me the link and I will have a look, I think the datamodel is different then that I currently think.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 11:13:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-value-based-on-date-between-a-range/m-p/897138#M8113</guid>
      <dc:creator>JarroVGIT</dc:creator>
      <dc:date>2020-01-12T11:13:30Z</dc:date>
    </item>
  </channel>
</rss>

