<?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: Calculated column with value from another table based on date range and another value in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2650917#M81237</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="405573" data-lia-user-login="pgeorgieff1" class="lia-mention lia-mention-user"&gt;pgeorgieff1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this as a calculated column on your Tasks table, but I'm not sure everything here is compatible with Direct Query, to be honest:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;..workingHours =
CALCULATE(
	VAR __empIdRow = VALUES(TasksTable[Employee ID])
	VAR __compDateRow = VALUES(TasksTable[Completed Date])
	RETURN
	MAXX(
		FILTER(
			workHoursTable,
			workHoursTable[Employee ID] = __empIdRow
			&amp;amp;&amp;amp; workHoursTable[Start date] &amp;lt;= __compDateRow
			&amp;amp;&amp;amp; workHoursTable[End date] &amp;gt;= __compDateRow
		),
		workHoursTable[Working hrs]
	)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pete&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2022 15:57:55 GMT</pubDate>
    <dc:creator>BA_Pete</dc:creator>
    <dc:date>2022-07-20T15:57:55Z</dc:date>
    <item>
      <title>Calculated column with value from another table based on date range and another value</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2649939#M81208</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables in DirectQuery mode: Tasks and Work Hours.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&amp;nbsp; &amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The table Tasks shows how much an employee spent on task on particular day.&lt;/P&gt;&lt;P&gt;Work Hours shows how much a person is available between two dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a column Working hours from Table Work Hours to Table Tasks based on Employee ID and Completed Date. I also want to add another column Total hrs / day, which calculates how many hours an Employee spent in a day again based on Employee ID and Completed Date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In excel I achieved this by the following formulas:&lt;/P&gt;&lt;P&gt;For working hrs:&amp;nbsp;=INDEX(M4:M9;MATCH(1;(E4=L4:L9)*(C4&amp;gt;=N4:N9)*(C4&amp;lt;=O4:O9);0))&lt;/P&gt;&lt;P&gt;For&amp;nbsp;Total hrs / day: SUMIFS(F4:F11;C4:C11;C4;E4:E11;E4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me add those columns in the table Tasks?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 09:34:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2649939#M81208</guid>
      <dc:creator>pgeorgieff1</dc:creator>
      <dc:date>2022-07-20T09:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column with value from another table based on date range and another value</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2650917#M81237</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="405573" data-lia-user-login="pgeorgieff1" class="lia-mention lia-mention-user"&gt;pgeorgieff1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this as a calculated column on your Tasks table, but I'm not sure everything here is compatible with Direct Query, to be honest:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;..workingHours =
CALCULATE(
	VAR __empIdRow = VALUES(TasksTable[Employee ID])
	VAR __compDateRow = VALUES(TasksTable[Completed Date])
	RETURN
	MAXX(
		FILTER(
			workHoursTable,
			workHoursTable[Employee ID] = __empIdRow
			&amp;amp;&amp;amp; workHoursTable[Start date] &amp;lt;= __compDateRow
			&amp;amp;&amp;amp; workHoursTable[End date] &amp;gt;= __compDateRow
		),
		workHoursTable[Working hrs]
	)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 15:57:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2650917#M81237</guid>
      <dc:creator>BA_Pete</dc:creator>
      <dc:date>2022-07-20T15:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column with value from another table based on date range and another value</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2656894#M81508</link>
      <description>&lt;P&gt;Hi Pete,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did lots of transformation which delayed me with the reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are no error in the rows, but all of them are blank. Have you got an idea what the reason can be?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Philip&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jul 2022 14:30:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2656894#M81508</guid>
      <dc:creator>pgeorgieff1</dc:creator>
      <dc:date>2022-07-23T14:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column with value from another table based on date range and another value</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2656972#M81512</link>
      <description>&lt;P&gt;Hi, Pete,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help. It works only in import mode. Still it's very useful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2022 10:01:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Calculated-column-with-value-from-another-table-based-on-date/m-p/2656972#M81512</guid>
      <dc:creator>pgeorgieff1</dc:creator>
      <dc:date>2022-07-24T10:01:22Z</dc:date>
    </item>
  </channel>
</rss>

