<?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: Backward scheduling based on working time DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3344383#M125543</link>
    <description>&lt;P&gt;Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2023 23:28:41 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2023-07-21T23:28:41Z</dc:date>
    <item>
      <title>Backward scheduling based on working time DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3337746#M125198</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im trying to create a calculated Column by DAX that will give me the Completion-Date for every Job-No using the tables shown below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the Delivery-Date of the Order-Table, the Completion-Dates for the respective Job are to be scheduled backward based on the needed Time for every Job.&amp;nbsp;In addition, scheduling should take into account working hours and weekends.&lt;/P&gt;&lt;P&gt;I already have a simple scheduling based on days and without considering working hours and weekends&amp;nbsp;(Code below) - Thanks to &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example for Order-No. 111 the results for every Job-No should be:&lt;/P&gt;&lt;P&gt;Job-No. 4: Completion-Date = 14.08.2023 12:00 AM (Same as Delivery-Date)&lt;/P&gt;&lt;P&gt;Job-No. 3: Completion-Date = 11.08.2023 03:59 PM (Because of the Weekend)&lt;/P&gt;&lt;P&gt;Job-No. 2: Completion-Date = 11.08.2023 11:12 AM&lt;/P&gt;&lt;P&gt;Job-No. 1: Completion-Date = 09.08.2023 03:12 PM &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be great if someone could help me.&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Completion Date = 
    VAR CurrentOrderTable = CALCULATETABLE(OPERATION_TABLE, ALLEXCEPT(OPERATION_TABLE, OPERATION_TABLE[Operation-No.]))

    VAR TableAfter = FILTER(CurrentOrderTable, OPERATION_TABLE[Job-No.] &amp;gt; EARLIER(OPERATION_TABLE[Job-No.]))

    VAR NumberOfDays = SUMX( TableAfter, OPERATION_TABLE[Time in days])

    VAR Delivery = RELATED(ORDER_TABLE[DELIVERY])

    RETURN Delivery - NumberOfDays&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 05:55:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3337746#M125198</guid>
      <dc:creator>MMZTM</dc:creator>
      <dc:date>2023-07-19T05:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Backward scheduling based on working time DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3344383#M125543</link>
      <description>&lt;P&gt;Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 23:28:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3344383#M125543</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-07-21T23:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Backward scheduling based on working time DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3346190#M125646</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;Thanks for the links. I hope I have taken all the hints into account now.&lt;/P&gt;&lt;P&gt;I have been looking for a similar discussion on my topic in this forum for quite some time - unfortunately without success so far.&lt;/P&gt;&lt;P&gt;Based on the Delivery-Date of the Order-Table, the Completion-Dates for the respective Job are to be scheduled backward based on the needed Time for every Job.&amp;nbsp;In addition, scheduling should take into account working hours and weekends.&lt;/P&gt;&lt;P&gt;I already have a simple scheduling based on days and without considering working hours and weekends&amp;nbsp;(Code below) - Thanks to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/317289" target="_blank" rel="noopener"&gt;@tamerj1&lt;/A&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;Please let me know if I have understood the hints in the links correctly and this is the right way to post &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be great if someone could help me.&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;&lt;P&gt;Here is the Sample file in .pbix-format, the Basic-Data as .csv and .xlsx-format.&lt;/P&gt;&lt;P&gt;&lt;A href="https://ztmueller-my.sharepoint.com/:f:/g/personal/manuel_mueller_ztm-mueller_de/EoPPSgFaIxVIsSlepjPeUSwBN537RmAzo1aHKVQ_ZpCu1g?e=lEXTTL" target="_blank" rel="noopener"&gt;PowerBI_Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also in the following the Relationships:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The expecting Result for the Compleation-Date for Order.No 111 should be:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Order-No&lt;/TD&gt;&lt;TD&gt;Job-No&lt;/TD&gt;&lt;TD&gt;Time in Minutes&lt;/TD&gt;&lt;TD&gt;Completion-Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1056&lt;/TD&gt;&lt;TD&gt;09.08.2023 03:12 PM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;720&lt;/TD&gt;&lt;TD&gt;11.08.2023 11:12 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;287&lt;/TD&gt;&lt;TD&gt;11.08.2023 03:59 PM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;241&lt;/TD&gt;&lt;TD&gt;14.08.2023 12:00 AM&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 24 Jul 2023 09:33:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3346190#M125646</guid>
      <dc:creator>MMZTM</dc:creator>
      <dc:date>2023-07-24T09:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Backward scheduling based on working time DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3354045#M125994</link>
      <description>&lt;P&gt;Thank you for the sample data and the expected result.&amp;nbsp; I think I understand the request, and will think about a potential approach.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why is the Delivery-DateAndTime pegged at noon rather than midnight?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 20:32:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3354045#M125994</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-07-27T20:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Backward scheduling based on working time DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3354735#M126022</link>
      <description>&lt;P&gt;Thank you so much for checking out!! I really hope that there is a solution for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is actually no reason for this. I just set it that way.&lt;/P&gt;&lt;P&gt;The only important thing for me would be that the time is within the working hours - so between 8:00 and 16:00.&lt;/P&gt;&lt;P&gt;But it would be no problem, if it is necessary for the calculation to set the time to midnight.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 06:26:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3354735#M126022</guid>
      <dc:creator>MMZTM</dc:creator>
      <dc:date>2023-07-28T06:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Backward scheduling based on working time DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3355322#M126073</link>
      <description>&lt;P&gt;Here is the basic approach&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Completion-Date = 
var j = SELECTEDVALUE(OPERATION_TABLE[Job-No.])
var mt = max(ORDER_TABLE[Delivery-DateAndTime])
// cumulative minutes from the current step to the end
var m = 0+CALCULATE(sum(OPERATION_TABLE[Time in Minutes]),OPERATION_TABLE[Job-No.]&amp;gt;j)
// series of minutes going back from the delivery date. Large padding ( * 10 ) to cover weekend and non working hour gaps. May need adjustment.
var s = ADDCOLUMNS(GENERATESERIES(0,m*10),"ts",mt-divide([Value],1440))
// filter out rows for weekends and non-working hours
var f = filter(s,WEEKDAY([ts],1) in {2,3,4,5,6} &amp;amp;&amp;amp; HOUR([ts])&amp;gt;=8 &amp;amp;&amp;amp; HOUR([ts])&amp;lt;16)
// count backwards and cut off
var t = topn(m+1,f,[ts],DESC)
// flip sort order and get first (earliest) row.
var r = topn(1,t,[ts],asc)
// return the timestamp for that  value
return concatenatex(r,[ts]) &lt;/LI-CODE&gt;
&lt;P&gt;Based on your sample data this results in&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see it still needs fine tuning, especially there needs to be a discussion on which minutes to include and which to exclude.&amp;nbsp; See attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 12:15:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Backward-scheduling-based-on-working-time-DAX/m-p/3355322#M126073</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-07-28T12:15:36Z</dc:date>
    </item>
  </channel>
</rss>

