<?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: Unable to get correct sum for total working hours in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2885040#M93491</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="441663" data-lia-user-login="dudeeee" class="lia-mention lia-mention-user"&gt;dudeeee&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my test table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try following DAX to create measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;First Operation = MINX(FILTER(ALL('Table'),'Table'[Day] = SELECTEDVALUE('Table'[Day])),'Table'[Operation])

Last Operation = MAXX(FILTER('Table','Table'[Day] = SELECTEDVALUE('Table'[Day])),'Table'[Operation])

Hours = IF(ISINSCOPE('Table'[Year]),DATEDIFF([First Operation],[Last Operation],HOUR),SUMX('Table',DATEDIFF([First Operation],[Last Operation],HOUR)))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result you want:&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;/P&gt;
&lt;P&gt;Yadong Fang&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 08:54:39 GMT</pubDate>
    <dc:creator>v-yadongf-msft</dc:creator>
    <dc:date>2022-11-04T08:54:39Z</dc:date>
    <item>
      <title>Unable to get correct sum for total working hours</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2838517#M90642</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I am trying to calculate the total working hours from the given table between the date and time range. For each day I am getting the correct hours by subtracting two timestamps. But in the case of the total, the subtraction yields the hours between the two date ranges which is not what I need.&lt;BR /&gt;I want the sum of the total working hours which is the correct result. How can I achieve this and what am I doing wrong?&lt;BR /&gt;Here is the power bi visual table showing the data.&lt;BR /&gt;&lt;BR /&gt;The measure formula I have used :&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Total Working Hours = &lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Lift First]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[Lift Last]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;HOUR&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;Here First Operation and Last Operation are both measures that gives min and max timestamp respectively.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Year&lt;/TD&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;Day&lt;/TD&gt;&lt;TD&gt;First Operation&lt;/TD&gt;&lt;TD&gt;Last Operation&lt;/TD&gt;&lt;TD&gt;Total working hours&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2022&lt;/TD&gt;&lt;TD&gt;September&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;9/5/2022 6:00:04 AM&lt;/TD&gt;&lt;TD&gt;9/5/2022 1:06:02 PM&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2022&lt;/TD&gt;&lt;TD&gt;September&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;9/11/2022 5:07:46 AM&lt;/TD&gt;&lt;TD&gt;9/11/2022 1:12:36 PM&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Total&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;9/5/2022 6:00:04 AM&lt;/TD&gt;&lt;TD&gt;9/11/2022 1:12:36 PM&lt;/TD&gt;&lt;TD&gt;151&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 13 Oct 2022 06:58:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2838517#M90642</guid>
      <dc:creator>dudeeee</dc:creator>
      <dc:date>2022-10-13T06:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get correct sum for total working hours</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2838566#M90644</link>
      <description>&lt;P&gt;Sumx&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 06:38:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2838566#M90644</guid>
      <dc:creator>RichardOfSydney</dc:creator>
      <dc:date>2022-10-13T06:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get correct sum for total working hours</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2838696#M90658</link>
      <description>&lt;P&gt;can you elaborate in my problem's context?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 07:26:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2838696#M90658</guid>
      <dc:creator>dudeeee</dc:creator>
      <dc:date>2022-10-13T07:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get correct sum for total working hours</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2885040#M93491</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="441663" data-lia-user-login="dudeeee" class="lia-mention lia-mention-user"&gt;dudeeee&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my test table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try following DAX to create measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;First Operation = MINX(FILTER(ALL('Table'),'Table'[Day] = SELECTEDVALUE('Table'[Day])),'Table'[Operation])

Last Operation = MAXX(FILTER('Table','Table'[Day] = SELECTEDVALUE('Table'[Day])),'Table'[Operation])

Hours = IF(ISINSCOPE('Table'[Year]),DATEDIFF([First Operation],[Last Operation],HOUR),SUMX('Table',DATEDIFF([First Operation],[Last Operation],HOUR)))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result you want:&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;/P&gt;
&lt;P&gt;Yadong Fang&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 08:54:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Unable-to-get-correct-sum-for-total-working-hours/m-p/2885040#M93491</guid>
      <dc:creator>v-yadongf-msft</dc:creator>
      <dc:date>2022-11-04T08:54:39Z</dc:date>
    </item>
  </channel>
</rss>

