<?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 Help with calculating specific delay time per day in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-calculating-specific-delay-time-per-day/m-p/3256485#M120280</link>
    <description>&lt;P&gt;Hi, I am trying to make a report that would give the delay&amp;nbsp;time per day (which would give me the run time per day to get approximate TPH). An example delay data table is formatted as shown below.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I have to calculate tons per hour for every day using another table with production information, I created a Calendar table (just a one-column table with only the dates using the CALENDAR() function) that is connected with both the delay table and production table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am struggling to calculate the number of hours of delay time per day with DelayType 0 as a column in the calendar table with the format shown below using the previous delay table as an example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried making a calculated column using DATEDIFF() but I am struggling to get only the entries with DelayType of 0 as well as how to deal with delays that span for multiple days (For example, 05/26/2023 falls within the 4th entry of the delay table so the total delay time for that day would be 24 hours).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any help or guidance on what I can do to get the final formatted Calendar table. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 27 May 2023 20:52:03 GMT</pubDate>
    <dc:creator>Paradox1023</dc:creator>
    <dc:date>2023-05-27T20:52:03Z</dc:date>
    <item>
      <title>Help with calculating specific delay time per day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-calculating-specific-delay-time-per-day/m-p/3256485#M120280</link>
      <description>&lt;P&gt;Hi, I am trying to make a report that would give the delay&amp;nbsp;time per day (which would give me the run time per day to get approximate TPH). An example delay data table is formatted as shown below.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I have to calculate tons per hour for every day using another table with production information, I created a Calendar table (just a one-column table with only the dates using the CALENDAR() function) that is connected with both the delay table and production table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am struggling to calculate the number of hours of delay time per day with DelayType 0 as a column in the calendar table with the format shown below using the previous delay table as an example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried making a calculated column using DATEDIFF() but I am struggling to get only the entries with DelayType of 0 as well as how to deal with delays that span for multiple days (For example, 05/26/2023 falls within the 4th entry of the delay table so the total delay time for that day would be 24 hours).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any help or guidance on what I can do to get the final formatted Calendar table. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 May 2023 20:52:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-calculating-specific-delay-time-per-day/m-p/3256485#M120280</guid>
      <dc:creator>Paradox1023</dc:creator>
      <dc:date>2023-05-27T20:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help with calculating specific delay time per day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-calculating-specific-delay-time-per-day/m-p/3256863#M120299</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="567370" data-lia-user-login="Paradox1023" class="lia-mention lia-mention-user"&gt;Paradox1023&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;Total Delay Time due to DelayType 0 (hour) =&lt;BR /&gt;SUMX (&lt;BR /&gt;FILTER (&lt;BR /&gt;CROSSJOIN ( ALLSELECTED ( 'Delay Table' ), VALUES ( 'Calendar'[Date] ) ),&lt;BR /&gt;'Delay Table'[Delay Type] = 0&lt;BR /&gt;&amp;amp;&amp;amp; 'Delay Table'[DelayStartTime] &amp;lt;= 'Calendar'[Date]&lt;BR /&gt;&amp;amp;&amp;amp; 'Delay Table'[DelayEndTime] &amp;gt;= 'Calendar'[Date]&lt;BR /&gt;),&lt;BR /&gt;DATEDIFF (&lt;BR /&gt;MAX ( 'Delay Table'[DelayStartTime], 'Calendar'[Date] ),&lt;BR /&gt;MIN ( 'Delay Table'[DelayEndTime], 'Calendar'[Date] ),&lt;BR /&gt;MINUTE&lt;BR /&gt;) / 60&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 17:47:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-calculating-specific-delay-time-per-day/m-p/3256863#M120299</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-05-28T17:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help with calculating specific delay time per day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-calculating-specific-delay-time-per-day/m-p/3258670#M120423</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="567370" data-lia-user-login="Paradox1023" class="lia-mention lia-mention-user"&gt;Paradox1023&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your screenshot, I think you don't need to create a relationship between Calendar Table and Delay Table, due to datetime type column in Delay table and date type column in Calendar.&lt;/P&gt;
&lt;P&gt;You can try this code to create a measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Total Delay Time due to DelayType 0 (hour) = 
VAR _CROSSJOIN =
    FILTER (
        GENERATE (  ALLSELECTED('Delay Table') , CALCULATETABLE(VALUES ( 'Calendar'[Date] ),ALLSELECTED('Calendar')) ),
        'Delay Table'[DelayType] = 0
            &amp;amp;&amp;amp; DATEVALUE ( 'Delay Table'[DelayStartTime] ) &amp;lt;= 'Calendar'[Date]
            &amp;amp;&amp;amp; DATEVALUE ( 'Delay Table'[DelayEndTime] ) &amp;gt;= 'Calendar'[Date]
    )
VAR _AddDuartion =
    ADDCOLUMNS (
        _CROSSJOIN,
        "Duration",
            VAR _MIN =
                MINX (
                    FILTER (
                        _CROSSJOIN,
                        AND (
                            'Delay Table'[DelayStartTime] = EARLIER ( 'Delay Table'[DelayStartTime] ),
                            'Delay Table'[DelayEndTime] = EARLIER ( 'Delay Table'[DelayEndTime] )
                        )
                    ),
                    [Date]
                )
            VAR _MAX =
                MAXX (
                    FILTER (
                        _CROSSJOIN,
                        AND (
                            'Delay Table'[DelayStartTime] = EARLIER ( 'Delay Table'[DelayStartTime] ),
                            'Delay Table'[DelayEndTime] = EARLIER ( 'Delay Table'[DelayEndTime] )
                        )
                    ),
                    [Date]
                )
            RETURN
                SWITCH (
                    TRUE (),
                    [Date] = _MIN
                        &amp;amp;&amp;amp; [Date] = _MAX, [Duration (hour)],
                    [Date] &amp;lt;&amp;gt; _MIN
                        &amp;amp;&amp;amp; [Date] &amp;lt;&amp;gt; _MAX, 24,
                    [Date] = _MIN
                        &amp;amp;&amp;amp; [Date] &amp;lt;&amp;gt; _MAX,
                        DATEDIFF ( [DelayStartTime], [Date] + 1, MINUTE ) / 60,
                    [Date] &amp;lt;&amp;gt; _MIN
                        &amp;amp;&amp;amp; [Date] = _MAX, DATEDIFF ( [Date], [DelayEndTime], MINUTE ) / 60
                )
    )
RETURN
   SUMX(FILTER(_AddDuartion,[Date] = MAX('Calendar'[Date])),[Duration])+0&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 03:20:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-calculating-specific-delay-time-per-day/m-p/3258670#M120423</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-30T03:20:20Z</dc:date>
    </item>
  </channel>
</rss>

