<?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: Grand total of datediff not correct in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1173003#M18166</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;This would be your measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DateDiff = 
IF(HASONEVALUE('Table'[Start]);
    DATEDIFF(MIN('Table'[Start]);MIN('Table'[End]);DAY);
    SUMX(SUMMARIZE('Table';'Table'[Worker ID];'Table'[Start];'Table'[End];"Diff"; CALCULATE(DATEDIFF(MIN('Table'[Start]);MIN('Table'[End]);DAY)));[Diff])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As seen here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;File is &lt;A href="https://1drv.ms/u/s!AvU6hhKLfmEcgdh6elMCPeqNpb93pQ?e=VBX7qV" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pls mark as &lt;STRONG&gt;solution&lt;/STRONG&gt; if so. Thumbs up for the effort appreciated!&lt;/P&gt;&lt;P&gt;Groet, Steve.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jun 2020 06:35:32 GMT</pubDate>
    <dc:creator>stevedep</dc:creator>
    <dc:date>2020-06-22T06:35:32Z</dc:date>
    <item>
      <title>Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1163949#M17864</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I have a simple statement:&amp;nbsp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;TimeToComplete = DATEDIFF([DateRaised],[DateCompleted],DAY).&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am able to filter by employee and the TimeToComplete column is correct for each of the employee's entries.&amp;nbsp; However, the Grand Total is equal to the sum of all employees' TimeToComplete.&amp;nbsp; I need to have the Grand Total be only the sum of the selected employee.&amp;nbsp; What am I doing wrong?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 16 Jun 2020 19:10:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1163949#M17864</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-16T19:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1164006#M17866</link>
      <description>&lt;P&gt;please explain what "selected employee" means. Selected where? In a slicer?&lt;/P&gt;&lt;P&gt;What's the data model looking like?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 19:52:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1164006#M17866</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-16T19:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1167949#M17953</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;I have the same issue, please allow me to explain.&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;From a report with time logs I have created 3 measures&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Time Clock IN = calculate(MIN(Raw_data[Time]),FILTER(Raw_data,Raw_data[Gebeurtenis]="AccessOK"&amp;amp;&amp;amp;Raw_data[Ingang gebied]="CLock IN"))&lt;BR /&gt;Time Clock OUT = calculate(MAX(Raw_data[Time]),FILTER(Raw_data,Raw_data[Gebeurtenis]="AccessOK"&amp;amp;&amp;amp;Raw_data[Ingang gebied]="Clock OUT UIT"))&lt;BR /&gt;Time diff = IFERROR(DATEDIFF([Time Clock IN],[Time Clock OUT],MINUTE)/60,0)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Each single row (date / employee) result for the measure Time worked is correct, only the total or DateToMonth is showing the numbers as expected.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;&lt;FONT&gt;Any help is much appreciated !&lt;img /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Jun 2020 07:25:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1167949#M17953</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-18T07:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1172602#M18142</link>
      <description>&lt;P&gt;&lt;FONT&gt;&lt;SPAN&gt;Meantime I figured out&amp;nbsp; how you can add up measures that are related to time stamps correctly.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;SPAN&gt;1a) Original measure &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;SPAN&gt;Time Clock IN = calculate(MIN(Raw_data[Time]),FILTER(Raw_data,Raw_data[Gebeurtenis]="AccessOK"&amp;amp;&amp;amp;Raw_data[Ingang gebied]="CLock IN")) &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;SPAN&gt;2a) and then added another measure&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;FONT&gt;&lt;FONT&gt;&lt;SPAN&gt;Time Clock IN&lt;/SPAN&gt;&lt;/FONT&gt; workable=if(countrows(values(DCalendar[Date]))=1,[Time Clock IN],sumx(values(DCalendar[Date]),[Time Clock IN]))&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;FONT&gt;&lt;SPAN&gt;1b) Original measure &lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;SPAN&gt;Time Clock OUT = calculate(MAX(Raw_data[Time]),FILTER(Raw_data,Raw_data[Gebeurtenis]="AccessOK"&amp;amp;&amp;amp;Raw_data[Ingang gebied]="Clock OUT UIT"))&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;2b) &lt;FONT&gt;&lt;SPAN&gt;&lt;FONT&gt;&lt;SPAN&gt;and then added another measure&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;FONT&gt;&lt;FONT&gt;&lt;SPAN&gt;Time Clock IN&lt;/SPAN&gt;&lt;/FONT&gt; Correct=if(countrows(values(DCalendar[Date]))=1,[Time Clock OUT],sumx(values(DCalendar[Date]),[Time Clock OUT]))&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;3) Calculate hours worked&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Nett time&lt;/SPAN&gt;&lt;FONT&gt;&lt;FONT&gt;&lt;SPAN&gt; = IFERROR(DATEDIFF([Time Clock IN Correct],[Time Clock OUT Correct],MINUTE)/60,0)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;FONT&gt;4)a Deviation to calculate overtime hours &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Time diff=&lt;FONT&gt;&lt;FONT&gt;[Nett Time]-[ContractHours]&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;4b)&amp;nbsp;&lt;FONT&gt;&lt;SPAN&gt;&lt;FONT&gt;&lt;SPAN&gt;and then added another measure&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;FONT&gt;Overtime hours correct= &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT&gt;if(countrows(values(DCalendar[Date]))=1,[&lt;FONT&gt;&lt;FONT&gt;&lt;SPAN&gt;Time diff&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;],sumx(values(DCalendar[Date]),[&lt;FONT&gt;&lt;FONT&gt;&lt;SPAN&gt;Time diff&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;]))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps "b" are resulting in correct sum up / grand total.&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;I am very aware that steps "a" are not necessary to create, as you can integrate them in step b.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;It is just to show you the direction how I solved my issue.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 21:31:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1172602#M18142</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-21T21:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1172606#M18143</link>
      <description>&lt;P&gt;you have not specified what you expect the total to show. Should it be the sum of the computed values?&amp;nbsp; In that case you need to use HASONEVALUE() or ISINSCOPE() to distinguish between individual items in the visual and the totals.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the totals you would then have to use a SUMX function. Technically you could also use SUMX for the individual items but it would be overkill since it would ony ever sum up one item.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 21:40:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1172606#M18143</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-21T21:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1173003#M18166</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;BR /&gt;This would be your measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DateDiff = 
IF(HASONEVALUE('Table'[Start]);
    DATEDIFF(MIN('Table'[Start]);MIN('Table'[End]);DAY);
    SUMX(SUMMARIZE('Table';'Table'[Worker ID];'Table'[Start];'Table'[End];"Diff"; CALCULATE(DATEDIFF(MIN('Table'[Start]);MIN('Table'[End]);DAY)));[Diff])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As seen here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;File is &lt;A href="https://1drv.ms/u/s!AvU6hhKLfmEcgdh6elMCPeqNpb93pQ?e=VBX7qV" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pls mark as &lt;STRONG&gt;solution&lt;/STRONG&gt; if so. Thumbs up for the effort appreciated!&lt;/P&gt;&lt;P&gt;Groet, Steve.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 06:35:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1173003#M18166</guid>
      <dc:creator>stevedep</dc:creator>
      <dc:date>2020-06-22T06:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1173631#M18201</link>
      <description>&lt;P&gt;That worked - thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 14:38:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1173631#M18201</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-22T14:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1173730#M18205</link>
      <description>&lt;P&gt;Glad I could help, thumbs up&amp;nbsp; for the effort would be great. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 15:11:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/1173730#M18205</guid>
      <dc:creator>stevedep</dc:creator>
      <dc:date>2020-06-22T15:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Grand total of datediff not correct</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/2734594#M83848</link>
      <description>&lt;P&gt;Great, thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 08:43:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Grand-total-of-datediff-not-correct/m-p/2734594#M83848</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-30T08:43:11Z</dc:date>
    </item>
  </channel>
</rss>

