<?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 Calculate the time difference in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference/m-p/3364920#M126523</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I hope you're all doing well.&lt;/P&gt;&lt;P&gt;I want to determine the total number of hours between the instances when the status was "On Hold" and the subsequent status.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this moment, I am using a calculated column&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total onhold difference(Business hours) = 
Var start_ = 
CALCULATE(
    MAX('Case history'[Created Date]),
    'Case history'[New Value] = "On Hold" &amp;amp;&amp;amp;
    'Case history'[Field] = "Status"
)

Var end_ = 
CALCULATE(
    MAX('Case history'[Created Date]),
    'Case history'[Old Value] = "On Hold" &amp;amp;&amp;amp;
    'Case history'[New Value] &amp;lt;&amp;gt; "On Hold" &amp;amp;&amp;amp;
    'Case history'[Field] = "Status"
)

return 
SUMX(
    CALCULATETABLE(
        'Calendar table',
        DATESBETWEEN('Calendar table'[Date],start_,end_),
        'Calendar table'[weekday] = 1
    ),
    MAX(MIN('Calendar table'[end],end_)-MAX('Calendar table'[start],start_),0)*24)&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;This calculated column Only calculates the latest on hold time difference because of&amp;nbsp; Max Function,&lt;BR /&gt;&lt;BR /&gt;As you can see in the photo below, the time which was marked in a black spot was excluded but I want to also include it in the calculation.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;I have attached the link to the power bi file&lt;BR /&gt;&lt;A title="Link to pbix" href="https://drive.google.com/file/d/1wtJIpwRktMROzQPfL3HSoecDEXbDj2K2/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/1wtJIpwRktMROzQPfL3HSoecDEXbDj2K2/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 04 Aug 2023 06:56:50 GMT</pubDate>
    <dc:creator>Kitu11</dc:creator>
    <dc:date>2023-08-04T06:56:50Z</dc:date>
    <item>
      <title>Calculate the time difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference/m-p/3364920#M126523</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I hope you're all doing well.&lt;/P&gt;&lt;P&gt;I want to determine the total number of hours between the instances when the status was "On Hold" and the subsequent status.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this moment, I am using a calculated column&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total onhold difference(Business hours) = 
Var start_ = 
CALCULATE(
    MAX('Case history'[Created Date]),
    'Case history'[New Value] = "On Hold" &amp;amp;&amp;amp;
    'Case history'[Field] = "Status"
)

Var end_ = 
CALCULATE(
    MAX('Case history'[Created Date]),
    'Case history'[Old Value] = "On Hold" &amp;amp;&amp;amp;
    'Case history'[New Value] &amp;lt;&amp;gt; "On Hold" &amp;amp;&amp;amp;
    'Case history'[Field] = "Status"
)

return 
SUMX(
    CALCULATETABLE(
        'Calendar table',
        DATESBETWEEN('Calendar table'[Date],start_,end_),
        'Calendar table'[weekday] = 1
    ),
    MAX(MIN('Calendar table'[end],end_)-MAX('Calendar table'[start],start_),0)*24)&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;This calculated column Only calculates the latest on hold time difference because of&amp;nbsp; Max Function,&lt;BR /&gt;&lt;BR /&gt;As you can see in the photo below, the time which was marked in a black spot was excluded but I want to also include it in the calculation.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;I have attached the link to the power bi file&lt;BR /&gt;&lt;A title="Link to pbix" href="https://drive.google.com/file/d/1wtJIpwRktMROzQPfL3HSoecDEXbDj2K2/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/1wtJIpwRktMROzQPfL3HSoecDEXbDj2K2/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Aug 2023 06:56:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference/m-p/3364920#M126523</guid>
      <dc:creator>Kitu11</dc:creator>
      <dc:date>2023-08-04T06:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the time difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference/m-p/3366807#M126619</link>
      <description>&lt;P&gt;Could &amp;nbsp;anyone please help me with this? Any help would be much appreciated:)&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 06:03:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference/m-p/3366807#M126619</guid>
      <dc:creator>Kitu11</dc:creator>
      <dc:date>2023-08-06T06:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the time difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference/m-p/3370167#M126805</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;it would be really helpful if you guys give me any suggestions on this topic &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Thank you from the mountain&amp;nbsp;&lt;BR /&gt;Regards&lt;/P&gt;&lt;P&gt;Kate&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 11:34:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference/m-p/3370167#M126805</guid>
      <dc:creator>Kitu11</dc:creator>
      <dc:date>2023-08-08T11:34:26Z</dc:date>
    </item>
  </channel>
</rss>

